- Home /
AddRelativeForce isn't staying 'relative'.
Whenever I use AddRelativeForce, it works if I'm facing the direction in which it's towards, but if I turn 180 degrees, eg. I travel back the way I came, it doesn't stay relative. It continues to push me in the direction it was.
rigidbody.AddRelativeForce(-Vector3.forward * 150);//Force pushes forwards
Thanks
lets see your object/project
I mean are you using that to go fowards because
vector3.forward should go forwards.
-vector3.forward should go backwards which tells me if its going forwards you messed up your object rotation in blender or whatever and you need to get that fixed for it to work.
Answer by Adamcbrz · Aug 18, 2013 at 01:31 PM
You are use a world relative Value with Vector3.forward you might want to use transform.forward instead.
I've tried that but now it's just adding a force that flips it over
AddRelativeForce is like Transform.Translate. They both take Vector3 forward/right and convert to transform.forward/right for you (see the docs.)
Say an object is rotated 30 degrees. AddRelForce(trans.forward)
would double-correct and push at 60 degrees.
Yes, this is definitely what's happening. I've tried many different things and still the same thing happens. All I want is a force to push along the object's local z axis no matter where it's facing...
@EvilSquid - you are mixing up the meaning of local and world. Try:
rigidbody.AddForce(-Vector3.forward * 150);
Nope, still the same thing is happening. Still continues pushing in the same direction.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
c# Object moves to global position when unparented 1 Answer
Local-Global error. 1 Answer