- Home /
Issues moving rigidbody with animation(C#)
Hello. I am trying have my character jump in Unity (Still kinda new to this), So I created an animation where the player squats down and then jumps in the air.
To do this, I had to move the gameObject with the rigidbody down and up during the animation. I figured I would have troubles with that, but I tried it anyway and when I start the game, the character can no longer move or look around and is not affected by gravity.
I also thought about just moving the children of the main object, but I still get the same result. Also, if you're wondering why I didn't just use a jump script, It's because I have one, but it's less realistic, because the player doesn't squat down first. Any ideas?
Answer by Lili-Shi · Jul 22, 2017 at 06:14 PM
Don't animate a character in such a way, that the rigidbody and stuff get's shuffed through space and time as well. Only animate the mesh.
Also: The actual movement of a character (note, that I am using "character" to refer to the GameObject", and not "mesh", as that would refer to the 3D-Model) occurs through coding. Often times one would use Rigidbody.AddForce()
to impulsively add force into the Y axis (Please read the documentation about Rigidbody.AddForce()).