- Home /
This post has been wikified, any user with enough reputation can edit it.
Question by
josemauriciob · Feb 25, 2015 at 05:35 AM ·
rotationmovemovingrotations
HOW stop object rotation when a another is not moving
Please how can i do that an object stops rotating when the other object is not moving.
I made rotate an object when other is moving, but my problem is I CAN NOT stop rotation when the other object is not moving.
here is my scene, and the here is the code i have to rotate when move.
link text var rotatecube : GameObject; var mycube : Vector3;
function Update () {
mycube = GameObject.FindGameObjectWithTag("cubito").transform.position;
rotatecube.transform.Rotate(mycube);
}
rotate-move-task-scene.zip
(124.8 kB)
Comment
The code you have written does not rotate rotatecube
only when mycube
moves. It rotates it when ever mycube
is not at (0,0,0).
You have to figure out a way to track when mycube moves. Transform.position does not give you that info unless you track changes in it over time.