Alright. So, in the project I’m working on, I have an object that I want to turn to face another object. Simply put: how. Although it seems like a good option, I can’t get transform variables to work. Also, for extra credit, can I make it reference a different object (with the same name) in each scene? Alternatively, the objects being rotated towards are immobile, so making the object rotate towards a given point would work as well. Thanks!
var damping:int=2;
var target:Transform;
var lookPos = target.position - transform.position;
lookPos.y = 0;
var rotation = Quaternion.LookRotation(lookPos);
transform.rotation = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime * damping);
someone else came up with the code but it worked for me
Take a look at Transform.LookAt
http://unity3d.com/support/documentation/ScriptReference/Transform.LookAt.html