I have some issues with a player character staying on the ground while using Anima2D Bones during a crouch <> idle transition animation.
This is my bone hierarchy and my character:
As you can see (green outlines), there is a collider on almost every limb. The root bone is the “pelvis”-bone.
My IdleToCrouch-Animation makes a transition from the left idle position to the right crouching position:
The problem is that during the transition, the character lifts up. Likewise, when exiting crouch and returning to idle, the feet get pushed into the ground somewhat:
How can I prevent this?
I have thought of two ideas: Either I animate the position as well or I remodel the bone hierarchy so that the parent bone is one of the feet. This way, the foot’s position should remain while the rest of the body gets rotated upwards. However, then I’d have to redo all animations because Unity’s animator (afaik) does not handle changed names/hierarchy too well.
Is there a more beautiful, reasonable approach? What is the way to go?
Open to all suggestions, thank you very much in advance!
Did you ever manage to resolve this? I am having a very similar issue whilst doing Gary Groves’ course ‘Build an Advanced 2D Platformer game in Unity’.
In his course we build a character (a robot) in a similar manner. The difference is that the collider is just a box collider. In his code, when the player ducks, the box collider halves in size and the centre point of the game object drops down. The problem is that the duck animation then wants to play from the lowered point, effectively meaning at the start of the animation the player is standing knee-deep in a puddle of ground.
I have managed to fix the ducking-down by raising animation higher up, so when the centre point drops, the character effectively remains in the same place and the remainder of the duck follows through with no issue.
However, things are a little more tricky when it comes to returning to a standing position. Since the centre point instantly snaps back to the higher position, unless I leave the transition duration to zero, effectively meaning he stands up unrealistically quickly, any attempt to animate from ducking back to standing happens a foot off the ground (as the ducking position is raised relative to the centre point don’t forget). So, unless I have to build another anim from ducking to standing, as well as modify my game mechanics to have an isStandingBackUp type state, this is going to be an issue.
I’m relatively new to this so there may well be a far more simple solution… someone please tell me what it is!
Thanks