- Home /
Look at like rotating around y axis
Hi!
Ive got a little problem - i would like my char to rotate relatively to other object around y axis similar as it it done with transform.LookAt() function
Could someone help me out?
Thanks in advance!
You're going to have to be more descriptive in your question. Would you like your characters body/head/camera to rotation relative to other objects?
Answer by aldonaletto · Sep 07, 2011 at 12:40 PM
You can use transform.RotateAround. The example below rotates the object around other defined in center at rps rotations per second. I don't remember if it also keeps looking at the center; if not, add a transform.LookAt(center); after RotateAround.
var center: Transform; //<- Drag the center object here var rps: float = 3; // speed in rotations per second
function Update() { transform.RotateAround (center.position, Vector3.up, rps * Time.deltaTime); }