Jumping with Mecanim synchronization
Posted
by
Abhishek Deb
on Game Development
See other posts from Game Development
or by Abhishek Deb
Published on 2013-10-19T04:07:39Z
Indexed on
2013/10/19
4:14 UTC
Read the original article
Hit count: 331
I am using Unity3D 4.1 for one of my projects. I have a robot character which is always running. I am using mecanim animation system.
What I really want:When I press Space bar, the character should jump up in the air, triggering an animation clip and then by the time it reaches the ground, the animation clip should also end.
What actually is happening:When I press Space bar, the character jumps in the air. Animation clip plays as it should, but ends way before it reaches the ground. So, it looks like he is running in the mid air.
What have I done: I have this humanoid robot setup with a jump animation bounded with the space bar key. Also, instead of using root motion, I am directly moving the robot from code.
//Jumping if(Input.GetKeyDown(KeyCode.Space)){ rigidbody.AddForce(Vector3.up*jumpVelocty); anim.SetBool("Jump",true); } else anim.SetBool("Jump",false);
Character's Details:
- Rigidbody = Mass:30, Freeze rotaion:x,y,z
- Capsule Collider = Material: metal, center(0,4.5,0), radius:1, height:11
- Script = jumpVelocity:20000
Jump Animation Clip: ~ 2 seconds. I am really out of ideas how to synchronize everything. Should I make the character jump in some other way so that it quickly comes down and touches the ground to match the animation clip? If yes, please provide a direction.
© Game Development or respective owner