- Home /
Question by
lukas_balaz · Jul 31, 2014 at 12:08 PM ·
movepositionlocal axis
rigidbody.MovePosition in local axes
I need object to move forward in local axes using rigidbody.MovePosition. Is it possible directly ? If not, how to calculate global position of object after moving forward (of course, i want to calculate it only, not to move object using transform.Translate or similar). Please help me, it is urgent.
Comment
Best Answer
Answer by Issah · Jul 31, 2014 at 01:10 PM
The local axis direction is rigidbody.transform.forward or you can use the camera.transform.forward too.
rigidbody.MovePosition(rigidbody.transform.forward + speed * Time.deltaTime);
I hope it's what you want.
Answer by VesuvianPrime · Jul 31, 2014 at 12:42 PM
You can calculate this very easily:
Vector3 someXVector = transform.rotation * Vector3.right * rightDistance;
Vector3 someYVector = transform.rotation * Vector3.up * upDistance;
Vector3 someZVector = transform.rotation * Vector3.forward * forwardDistance;
Your answer
![](https://koobas.hobune.stream/wayback/20220613155451im_/https://answers.unity.com/themes/thub/images/avi.jpg)