- Home /
Rigidbody velocity and transform.forward
Ok so here's the deal, I want my character to move forward relative to it's rotation, so i'm using a simple rotation scrip along with the rigid.velocity = transform.forward * vel, but whenever this command is running the Y velocity goes nuts, so it looks just like the character is gliding, is there any good way to fix that?
Answer by FlightOfOne · Jan 20, 2018 at 09:05 PM
when you directly change the velocity like you are doing, it ignores the mass of the object. It is recommended that you use rigidbody.AddForce() instead for manipulating physics objects.
In your case it would be:
if(_rigid.velocity.sqrMagnitude<_desiredVelocty* _desiredVelocty)
{
_rigid.AddRelativeForce(Vector3.forward * _desiredVelocty /* or speed */);
}
Your answer
![](https://koobas.hobune.stream/wayback/20220612150923im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Make a moving rigidbody treat a ramp of a certain angle as a wall 1 Answer
Setting a RigidBody's velocity messes with my custom gravity, not sure how to proceed. 0 Answers
Why do I get different rigidbody.velocity depending on angle? 1 Answer
Rigidbody angularvelocity shortest way 1 Answer
Getting a child (w/ rigidbody) to follow parent (w/ rigidbody) 0 Answers