- Home /
Freezing Rigidbody Rotation
Not sure what I'm doing wrong here. Trying to do a character movement script. He's moving fine, animation is playing, he is colliding with things and has gravity applied. But when he collides with stuff he starts to roll around since the character is pretty much just a ball with arms. I tried using the rigid body constraints and freezing the rotation to stop him from rolling around but it doesn't seem to work. Any ideas on what I'm doing wrong.
var speed : float = 5.0;
function Update ()
{
rigidbody.constraints = RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationY | RigidbodyConstraints.FreezeRotationZ;
rigidbody.constraints = RigidbodyConstraints.FreezePositionZ;
if(Input.GetButton("MoveRight"))
{
animation["Walk"].speed = 1.5;
animation.Play("Walk");
transform.Translate(Vector3.right * Time.deltaTime * speed);
}
}
Answer by Rett_ · Mar 05, 2013 at 07:24 PM
Use Character Controller for character movement, instead of a rigidbody.
Rigidbodies are supposed to be used with the physics system (They can be moved around by applying forces, they bounce, respond to friction etc.) which as far as I can tell is not what you need.