user2819531
user2819531

Reputation: 1

Unity 3D setting rotation and still use rigidbody

I have been working on an RTS game and am working on unit movement now. I have finished path finding as well as unit spacing, but I am coming across a big problem: when my units (tanks in this case) go over an incline, they stay parallel to the ground because I am setting their rotation based on Quaternion.LookRotation(distanceToDestination); so I can get a good rotation.

Is there a way that I can get the rigidbody to behave normally and still set the unit's rotation?

Upvotes: 0

Views: 979

Answers (1)

Thomas Ingham
Thomas Ingham

Reputation: 1102

You have two really simple-to-implement options.

  1. Add an enclosing empty for playing the role of your rigidbody. This will allow you to LookAt with your child item without affecting the trajectory of your main object.
  2. Lock the rotation of your rigid body using constraints and then manually override the Z axis with the normal of your contact point; and the Y axis with your target's inverse vector.

Hope this helps.

Upvotes: 1

Related Questions