x


Does setting the rotation of an object override the physics engine?

If I control a spaceship by changing its rotation directly, will that override any change the physics engine would have done? For instance, let's say my ship hits an asteroid, and the physics engine calculates that the front end should be knocked upwards. Would using a control scheme that sets the rotation directly allow the player to negate the torque by engaging the controls in any direction at time of impact?

more ▼

asked May 11 '12 at 06:50 PM

Harabeck gravatar image

Harabeck
63 5 7 10

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

Yes.

You would have to use rigidbody.AddTorque or rigidbody.AddRelativeTorque.

more ▼

answered May 11 '12 at 07:09 PM

Piflik gravatar image

Piflik
5.4k 17 27 45

Ok then. Would you know how to prevent this issue?

http://www.youtube.com/watch?v=NZQ4X1YL1Vo

The ship isn't turning on its axis properly. I've tried both of the following with identical results:

gameObject.rigidbody.AddRelativeTorque(Vector3.up*PitchYaw*modifier);

and

gameObject.rigidbody.AddForceAtPosition(-gameObject.transform.right*(PitchYaw*modifier),gameObject.transform.position-(gameObject.transform.forward4)); gameObject.rigidbody.AddForceAtPosition(gameObject.transform.right(PitchYaw*modifier),gameObject.transform.position+(gameObject.transform.forward*4));

The issue only arises when the ship is asymmetrical when viewed in profile relative to the axis of rotation. For instance, the ship in the video pitches up and down just fine. But I can also make a ship that yaws fine, but pitches weird, all based on the symmetry of the colliders that make up the ship. Also, note that I apply the thrusts to the center of gravity (or rather, move the children relative to the top object so that the objects position will be identical to the center of gravity).

May 11 '12 at 07:32 PM Harabeck
(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:

x1948
x1864
x230
x51

asked: May 11 '12 at 06:50 PM

Seen: 487 times

Last Updated: May 11 '12 at 07:32 PM