- Home /
Rigidbody player movement unrealistic velocity problem.
Hi. I am working on basic rigidbody player movement. I have tried this to move the player forward, but if I walk off a cliff I just walk on air while I am moving, but the velocity is local:
rigidbody.velocity = (transform.forward * moveSpeed * Time.deltaTime);
This does make the player fall off a cliff but it isn't local. So, how do I convert this to using local XYZ:
rigidbody.velocity.z = 100 * Time.deltaTime;
Thanks.
Comment
Best Answer
Answer by ScroodgeM · Jul 19, 2012 at 07:30 PM
Vector3 localizedSpeed = transform.InverseTransformDirection(rigidbody.velocity); localizedSpeed.z = 100; rigidbody.velocity = transform.TransformDirection(localizedSpeed);
P.S. if you need transform's forward speed is constant, you need set it to constant. use Time.deltaTime for move offsets, but not speeds
Thanks! Really, been searching for an answer since a long time.