|
I want to be able to have something to rotate to look at something, but I don't know how to make it accurate. I only want it to rotate on the Z axis. Any good way I could do this?
(comments are locked)
|
|
You can calculate the direction of the target and zero the z coordinate - this restricts the direction to the XY plane. Then you can calculate a Quaternion.FromToRotation from what you consider your forward direction to the target - if the forward direction of your object is the X axis, for instance, you should use Vector3.right as from direction:
var target: Transform;
...
var atDir = target.position-transform.position;
atDir.z = 0; // restricts direction to the XY plane
transform.rotation = Quaternion.FromToRotation(Vector3.right, atDir);
...
I want to rotate with physics, not with transform.
Sep 11 '11 at 03:08 AM
The BOOM
You have no reason to rotate with physics if you know the end result you're looking for. Physics should be used for unpredictable simulations. The results will be the same, you'd just be wasting CPU cycles using the physics engine.
Sep 11 '11 at 03:44 PM
PrimeDerektive
(comments are locked)
|
