x


Why my rigidbody object doesn't go straight?

I have a box collider and I apply

rigidbody.AddRelativeForce(Vector3.forward*z*velocitSpostamento, ForceMode.Force);
     rigidbody.AddRelativeTorque(Vector3.up*x*velocitSpostamento/2000, ForceMode.VelocityChange);

to move it, but instead of going straight, it curves

more ▼

asked Dec 04 '11 at 10:18 PM

anwe gravatar image

anwe
114 31 34 38

I'm sorry if my comment sounds silly, but isn't AddRelativeTorque meant to do just that? Turn your object according to physics? If you're turning and pushing forward, a curve is what to expect, no?

Dec 04 '11 at 10:53 PM gregzo
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

gregzo's comment is not silly, he's right. The difference between AddForce and AddRelativeForce is that AddRelativeForce applys relative to the object's rotation, while AddForce uses global directions. AddRelativeTorque is causing the object to spin, so the direction AddRelativeForce is applied in constantly changes along with it.

If you want to keep pushing it one direction while it spins, you'll want to use AddForce instead.

:edit: just realised gregzo and I were both making the assumption you applied this force repeatedly over time, which would result in it following a curving trajectory. It's also possible that it's curving downward because you did not disable gravity for the rigidbody!

more ▼

answered Dec 04 '11 at 10:57 PM

WillTAtl gravatar image

WillTAtl
697 2 4 9

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x2483
x1782
x662

asked: Dec 04 '11 at 10:18 PM

Seen: 809 times

Last Updated: Dec 05 '11 at 02:46 AM