- Home /
Question by
oinkoinkflapflap · Feb 17, 2014 at 10:11 AM ·
rotationlookatlocalglobal
Local Look Rotation
Hi, I'm attempting to make an arrow that shows which direction the target is when it's outside the centre of the screen, i want this arrow to be a plane with a texture and spin in a circle on the screen, i thought i'd use a lookat script which is set to ignore one axis and put it in front of the screen, but the script works globally and i don't know how to convert it to work locally, i assume this is what i need to do, the image shows what i'm going for
i want the plane always to be flat to the the screen, the idea is that target 2 is behind the camera, i can make this work until the camera moves and changes rotation, here is script i'm using;
var Target : Transform;
var damping = 2.0;
function Update () {
var Pos = Target.position - transform.position;
Pos.y = 0;
var rotation = Quaternion.LookRotation(Pos);
transform.rotation = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime * damping);
}
show.png
(11.7 kB)
Comment