- Home /
2D - Attaching Hinge Joint to Animated Sprite
Hi,
I'm new to Unity and teaching myself using tutorials at the moment. I'm trying to create a 2D game with a top down view of a character running and the player controls his arm movements.
I created an animated sprite of the character running using a character/sprite sheet showing the players feet moving and shoulders rotating back and forth as he runs - it does not include any arms.
For the arm I created three sprites (bicep, forearm and hand) and used the hinge joint to join them together like a chain. By adding limits and motors I'm thinking I could make the movements seem realistic.
The problem comes when I join the bicep to the running animation character/object. The hinge joint ignores the rotating of the shoulders in the animation so it looks unrealistic - the bicep stays stationary when it should be twisting/rotating with the shoulder. Is there a way to anchor the hinge joint to a point that moves with the animated movement?
Next I tried removing the animation from the game character and using a static sprite. I made that kinematic and applied a hinge joint so it should rotate on it's centre. When the arm is attached to the character this time the bicep moves with the shoulder blade. Unfortunately using the hinge joint motor settings I can only make him spin in one direction rather twist back and forth like he's running! I'm guessing I can make the character rotate back and forth by using some scripts but I haven't started looking at those yet.
Is there a way to make this work with the animated character sprite before I dive into scripting?!
Thanks for your help. Sorry for the long post!
Cheers,
Craig
I had the same problem I guess and would be interested to hear if you found a good solution to this, or if we approched this completly backwards.
In my case I wanted to have a dragon who I animated walking, flying and such, but I only wanted the tail to be affected naturally by enviroment and movement of the body. However when the body, which the tail was obviously attached to, moved in an animation the joints didn't follow smoothly. The only solution I found was to use Character Joints. But since this was a 2D sprite it feels wrong to use 3D components.
However, this worked in my example. There's probably better ways to do this and avoid mixing in 3D components in your 2D project so don't consider this an answer, but it works with some tweaking for the moment.
,