Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Godot 4] Bones in SkeletonIK chain detaching from mesh and behaving incorrectly #53358

Closed
J-L-42 opened this issue Oct 3, 2021 · 4 comments · Fixed by #53394
Closed

[Godot 4] Bones in SkeletonIK chain detaching from mesh and behaving incorrectly #53358

J-L-42 opened this issue Oct 3, 2021 · 4 comments · Fixed by #53394

Comments

@J-L-42
Copy link

J-L-42 commented Oct 3, 2021

Godot version

v4.0.dev.custom_build [90f8eb7]

System information

Manjaro Linux

Issue description

I tried to set up a SkeletonIK chain in Godot 4 (built from master), but had some very strange behaviour. Bones would detach themselves from the mesh and start spasming, as if they weren't quite sure how to orient themselves. I managed to reproduce the issue with this tutorial, which I updated to Godot 4 and attached below. You can see when you move the target position around that the arm separates itself from the hand and the shoulder, and sometimes starts to spin round and round. See below:

ik_godot4.mp4

I loaded up the same project in Godot 3.3.3 and it works as expected (as in, the arm stays attached to the hand). See below:

ik_godot3.mp4

Steps to reproduce

  1. Load the minimal reproduction project and open Character.tscn
  2. Play the IK on the SkeletonIK node
  3. Drag the TargetPosition node around
  4. The bones will start separating and spinning around

Minimal reproduction project

ik.zip

@TwistedTwigleg
Copy link
Contributor

I can confirm the issue occurs with the latest version on master. I'll see if I can figure out what is going on and make PR with a fix.

@TwistedTwigleg
Copy link
Contributor

TwistedTwigleg commented Oct 3, 2021

Initially I thought it was the automatic Maximio rig tool and it's strange bone forward directions it tends to use that was causing the issue, but I did some testing and it seems like that is not the case, as a 3D model that I know has a consistent bone direction of Y+ also has the same issue. Instead it seems like something with the rotation code in the SkeletonIK node either changed or one of the functions it relies on changed functionally. I suppose it could also be that one of the changes to the Skeleton node itself could have caused the issue.

The issue does not occur with the new Skeleton_Modification3DFABRIK, so it seems to be SkeletonIK specific. I'll see what I can do, but I'm not totally sure if I'll be able to find a fix (at least not quickly, as I don't totally understand how SkeletonIK calculates the rotation for the bones).

Edit: I kinda narrowed it down a bit. It seems to be the current_ori calculation in solve_simple_forwards that is causing the issue. It seems it calculates it right, and then immediately calculates it wrong, leading to it jittering back and forth.

@fire
Copy link
Member

fire commented Oct 4, 2021

@TwistedTwigleg I am contemplating removing SkeletonIK3D. Going to try it in my prs and report back. The proposal you mentioned to make SkeletonIK3D a standalone node with the stack internally was complicated. godotengine/godot-proposals#3099

@TwistedTwigleg
Copy link
Contributor

@fire - I think I found a fix that works, though because it solves rotation differently it gives a different (though valid) result when there is no magnet position (due to the infinite axes that can be selected when solving). #53394 contains the PR that seems to fix the issue.

For removing the SkeletonIK3D, I do not necessarily have any issues with removing it. I thought the plan was to keep it for Godot 4.0 for migration purposes though. Removing it would make IK maintenance easier though, as then there would just be a single source of IK to maintain.

For making the SkeletonIK3D use a stack internally, I think it's possible but it may require making minor modifications to the SkeletonModificationStack3D, I think, to get it working more seamlessly. That said, I haven't really tried it since it was just an idea, so I'm not sure how complicated it would be in actually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants