This command makes a 3D object look towards another object or location.
object.TurnTo(x,y,z,time)
or
object.TurnTo(Other3DObject,time)
x, y, z | The location where you want the object to look. |
time | The number of seconds the move will take (if omitted, the movement is immediate) |
This command is different from the LookAt command. The LookAt command makes your object constantly look at another object or location. The TurnTo command makes your object look toward the other object or position, but it makes no further attempts after any motion is made.
In the following code, you will be able to move a sphere with the arrow keys. Two other spheres will be created, one using the LookAt command, another using the TurnTo command.
oworld = New World(); ocamera = New Camera(oworld); sphere = oworld.CreateSphere(50,50,50,25,25); sphere2 = oworld.CreateSphere(50,50,50,25,25); sphere3 = oworld.CreateSphere(50,50,50,25,25); sphere2.SetPosition(-100,-100,0); sphere3.SetPosition(100,-100,0); Sphere3.LookAt(sphere); Sphere2.TurnTo(sphere,5); ocamera.MoveBack(1200); sphere.Walk(); //loop While(TRUE);