- Home /
How can you apply force or set the velocity of a rigidbidy on local axis?
In Unity is it possible to apply force or set the velocity of a rigidbody on local axis? If so, how can you do it? Thank you for your time.
Answer by ttmmiizz100 · Mar 17, 2019 at 02:03 PM
If you want to add force, you can use AddRelativeForce
as mentioned by @Eric5h5 at https://answers.unity.com/questions/39239/addforce-in-local-space.html
If you want to set the velocity you can do this, as mentioned by @aldonaletto at https://answers.unity.com/questions/193398/velocity-relative-to-local.html
var locVelocity = transform.InverseTransformDirection(rigidbody.velocity);
locVelocity.z = speed;
rigidbody.velocity = transform.TransformDirection(locVelocity);
Your answer
Follow this Question
Related Questions
How to apply relative force to Ball using another object? 0 Answers
How would I counteract the force of the velocity and set it to zero after the input has stopped? 3 Answers
Manually Apply Cars Collision Response Force 0 Answers
Collider question 0 Answers
ForceMode.Impulse Doesnt always fire. 2 Answers