• Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Question - Code Does GMS2 support Spine Inverse Kinematics?

ted234521

Member
Title says it all. When manipulating bones with functions such as bone_state_set (changing a bone's angle to track the mouse, for example), are IK constraints in Spine respected?

In my game I have a character holding a gun with two hands. In Spine, I want to constrain the secondary arm (holding the grip) to the gun so it will angle itself correctly when aiming. If I do this, will game maker correctly position the other bones as I manipulate the other arm?
 

Didjynn

Member
Well yes they say so but then I wonder why it's not working with me. I created the ik constraints in Spine and made my animations with it. But in game maker my legs have the wrong orientation, this is really annoying. I don't know what to do to fix that and I would like to avoid to fix it by code for my 25 different animations
 

rIKmAN

Member
It doesn't. I thought so, and was told so, and bought Spine, only to find out that it doesn't.

https://forum.yoyogames.com/index.php?threads/how-well-is-spine-supported.13822/

EDIT: oh, it was already posted.

Short answer: You can export animations made with IK in spine. But the IK do NOT work inside of GM (you can't set a "hand" bone to a location and see the IK solve the arms)
Did you update to Spine Pro?
If I'm remembering right from the other thread when you were saying IK didn't work you were using Spine Essentials and hadn't setup any IK at all - because you can't in Essentials and which is why it didn't work.

I haven't got around to re-exporting this old rig using Spine 3.7 and testing the skeleton in v2.2.2 yet, but you can see in this example that I'm moving around an IK target bone via code to follow the mouse and the IK for the legs is being solved.

This is inside GMS2... 2.0 or 2.1 I think - I'd have to check when I get home as this was a long time ago now.


Here's the same skeleton where I'm moving the hand IK target with the mouse, and the arm is bending as expected.


There were some other issues I had pre 3.7 runtime update with IK, but not anything that stopped it from working completely - it just didn't work quite right and those same examples I tested in v2.2.2 then did work correctly.

There have definitely been some fixes / changes made during the 3.7 runtime update which I think could make things go a bit wonky if not re-exported from 3.7.

If I can find it I'll test the rig from the gifs above as soon as I can find some time and make sure they still work as expected.
 
Last edited:

Didjynn

Member
I actually have the pro version.

Everything is nice and well in Spine.



Here you can see Spine on the left and Game Maker on the right, the "foot" are going up or down and they always keep this inclinaison. I really have no idea why, IK constraints are used between the foot and the leg, the foot just have a fixed rotation (so they are always perprendicular to the ground. They do not inherit from the leg's orientation but I don't think this is linked to the problem since when it plays the animations, the foot still keep this position
 

Didjynn

Member
I got my answer from Spine's forum :

The bad part about this is that GameMaker is in sync with an older version of Spine, where the latest things like IK stretch, or disabling inherit scale/rotation, and others aren't available for you to use. The good thing is that they should be in the process of updating their runtime.
 

rIKmAN

Member
I got my answer from Spine's forum :

The bad part about this is that GameMaker is in sync with an older version of Spine, where the latest things like IK stretch, or disabling inherit scale/rotation, and others aren't available for you to use. The good thing is that they should be in the process of updating their runtime.
How old was the post you found that information in?

The example skeleton that comes with Spine 3.7 that uses stretchy squashy IK runs fine (ie. just as it looks in the Spine IDE) in the latest version of GMS2 by just exporting from Spine and loading into GMS2. If it wasn't supported I would expect that example to fail.

It can be found in your Spine folder: \examples\stretchyman\stretchyman-stretchy-ik-pro.spine
You obviously need Spine Pro for access to the IK features.
 

Didjynn

Member
I got this answer in the last 24 hours from Spine's staff.

My problem isn't IK finally but the inheritance of rotation, I unchecked it to keep my foot in the right position for the ground.
 

rIKmAN

Member
I got this answer in the last 24 hours from Spine's staff.

My problem isn't IK finally but the inheritance of rotation, I unchecked it to keep my foot in the right position for the ground.
It sounds like maybe the staff member you spoke to isn't aware that GMS2 has been updated to use the 3.7 runtimes, as they are the latest runtimes.
I did get a similar response myself a while back, but that was when GMS2 used the 3.4 runtimes so that info was correct then.

Is your problem solved now or do you still have the issue with rotation / inheritance?

If you still have it, post the issue in the Spine Update 2.2.2 feedback thread and tag Dan to hopefully get an answer.
YYG are the only ones that can really answer how things such as that have been implemented into GMS2 on the back end.
 

Didjynn

Member
Sooo I'm back on this thread because I was right about the GMS2 update :p

Just kidding, I'm back here because I still have some troubles with the spine animations in GMS2. You did some in real time animations and it looks great, I would like to do that too but I don't understand which line of code I should use... maybe I missed it but I find no code line to move a bone. Can you tell me that please ?
 

rIKmAN

Member
Sooo I'm back on this thread because I was right about the GMS2 update :p

Just kidding, I'm back here because I still have some troubles with the spine animations in GMS2. You did some in real time animations and it looks great, I would like to do that too but I don't understand which line of code I should use... maybe I missed it but I find no code line to move a bone. Can you tell me that please ?
If you check the skeleton animations section of the manual all the functions you can use to access and modify skeleton properties are listed there.

To modify bone properties you use the following:
skeleton_bone_state_get()
skeleton_bone_state_set()
skeleton_bone_data_get()
skeleton_bone_data_set()

Make sure the read the manual for the slight differences between them and which one you want to use, as one uses the current frame of the skeleton and one uses the setup pose of the skeleton.

There is example code at the bottom of those pages of how to get and set the properties of a bone.
 

Didjynn

Member
ahhh okay thanks. I did read these but I did not understand it was permitting me to do that... Thanks again !
 

DukeSoft

Member
Please note that it does support IK now, but only 2 bones. If you want a hand, lower arm and upper arm, it doesn't work. Spine doesn't support multiple constraints..
 

rIKmAN

Member
Please note that it does support IK now, but only 2 bones. If you want a hand, lower arm and upper arm, it doesn't work. Spine doesn't support multiple constraints..
It also supported IK the last time you claimed it didn't, it's just that you were using Essentials and IK is Pro feature.

Not exactly sure what you mean by hand, lower arm and upper arm not working with IK?
Have you actually tested this in Pro?

Unless I'm misunderstanding you, then there are many examples of that (or a similar) setup working with IK, I posted one above with the cyborgs legs reacting to an IK bone being moved with the mouse.

I'm not sure how that was setup inside Spine as I'd have to dig out the project file (I didn't make it) but there are clearly more than 2 bones in the legs reacting via IK from the foot up to the hip, which is what you are saying isn't possible with a hand / lower arm / upper arm setup.
 

DukeSoft

Member
Hey @rIKmAN,

No, I actually bought Pro and tried to make a setup for a top down player: root (neck) -> left shoulder (static) -> upper arm -> lower arm -> hand.

I wanted the arm and hand to move using IK constraints - and wasn't able to do so in Spine. When asking how I could achieve this, this is the response I got from the team at spine:
Sorry for the late reply. Indeed, Spine only supports 2 bone IK. However, you apply apply multiple constraints to the same bone, e.g. an IK constraint plus a transform constraint
 

rIKmAN

Member
However, you apply apply multiple constraints to the same bone, e.g. an IK constraint plus a transform constraint
Is that meant to say "you can apply"?

If so then maybe that's what you need to do to get the results you are after and also maybe the way it was setup in the gif I posted of the legs, as that seems like it is exactly what you are trying to achieve except with arms (ie. multiple bones ( >2) reacting when setting a target IK bones position to the mouse position using the skeleton_bone_* functions)

There are definitely ways to get the setup you were were trying achieve even with the 2 bone IK system that Spine has in place - this section of this video shows how you can join multiple 2 bone contraints together for example - and I'm sure there are other methods to achieve the same goal.
 
Last edited:

DukeSoft

Member
Hmm.. What I wanted to accomplish might indeed be that - I just know that Spine IDE gave me errors when I tried to add multiple constraints (something about bones already connected or something like that) - I wanted to only move the hand (actually the weapon in the hand), and make sure the elbow always gets pushed outwards while the hand also has a constraint on a 90 degree angle. And then the same for the other arm + hand.

I just kinda gave up on it and am working on my own IK, and I don't feel like buying Spine Pro again for only this one time purpose.
 

rIKmAN

Member
Hmm.. What I wanted to accomplish might indeed be that - I just know that Spine IDE gave me errors when I tried to add multiple constraints (something about bones already connected or something like that) - I wanted to only move the hand (actually the weapon in the hand), and make sure the elbow always gets pushed outwards while the hand also has a constraint on a 90 degree angle. And then the same for the other arm + hand.

I just kinda gave up on it and am working on my own IK, and I don't feel like buying Spine Pro again for only this one time purpose.
As I said I'd have to look at the project file for the cyborg skeleton as it was done by someone else when they were learning Spine, so if I can find it I'll take a look and see.

Probably too late now but it might have been worth jumping on the Spine Discord and asking there, Erikari is active there and is really helpful - she does all the Spine tutorials / streams on the Esoteric Twitch Channel and knows her stuff.

If you already bought Pro you don't need to buy the licence again, it's a lifetime licence not a subscription.

edit:
Forgot to mention the runtime made by Nux might be worth you taking a look at also as that may be helpful to you.
 
Last edited:

DukeSoft

Member
Hey rIKmAN,

Thanks! Yeah I actually requested a refund because that was the sole reason I bought it, and the friendly folks from Esoteric refunded the program to me, so unfortunately I don't have the possibility to try it anymore.

I did see Nux's stuff indeed, looked very promising.

Maybe next time if I have to deal with IK and Spine again I'll give it another shot :)
 
Top