This question was
closed Dec 20, 2015 at 12:36 AM by
OctoMan for the following reason:
The question is answered, right answer was accepted
Rotate on z axis while move up and down
Hi,
i have AI Enemy ships following pathes through the scene. I am looking for a way to rotate them on the z axis when the are go up or down on some degrees (smoothly).
How would i get the last y-position and the currrent y-position to check if the ship goes up or down? The following doesn't work :/
cur_Position = transform.position;
if (cur_Position.y < last_Position.y)
{
transform.Rotate(Vector3.left*Time.deltaTime);
}
else
{
transform.Rotate(Vector3.right*Time.deltaTime);
}
last_Position = cur_Position;
what did i missid? isn't it working while on a path?
Comment
You'd be rotating 1 degree per second. It'd take 6 $$anonymous$$utes to make a full loop.
Try
public float degreesPerSecond = 360;
// .....
transform.Rotate(Vector3.left * degreesPerSecond * Time.deltaTime);
Yeah found out just a $$anonymous$$ ago, thanks :)