- Home /
Local Velocity
Does anyone know a way to edIt the velocity of a rigidbody relative to the transform's rotation? Like a local velocity?
Just curious, would this work as expected? transform.rigidbody.velocity = Vector3(transform.position.forward);
Comment
Best Answer
Answer by aldonaletto · Oct 14, 2011 at 10:59 PM
The rigidbody velocity is relative to the world, but if you transform the new velocity from local to the world space it will work. Your suggestion is almost ok - you should write:
// speed is the magnitude (float)
rigidbody.velocity = transform.forward * speed;
Ah, yes the Vector3 is not required there of course. Thank you!