- Home /
Question by
yesimarobot · May 14, 2010 at 01:48 PM ·
lookatrotatearoundorbit
Rotate Around and Look At Problem
I'm using the following code to get prototype for moving an object around a spherical object and keeping the object perpendicular to the sphere.
var speed = 100.0; var planet : Transform;
function Update () { var x = Input.GetAxis("Horizontal") Time.deltaTime speed *-1; transform.RotateAround(Vector3(0, -512, 0), Vector3.forward, x); transform.LookAt(planet); }
The result is sort of working. I see the following behavior when the object orbiting crosses the halfway point of the sphere. It rotates 180 on the z axis.
Comment
Your answer
Follow this Question
Related Questions
Indicator rotating around player 1 Answer
LookAt() and RotateAround() 1 Answer
Vector Alignment and Spacing 1 Answer
RotateAround() faster than rotate 1 Answer
How do you move a camera in a circle around a gameobject? 1 Answer