how can i make it so LookAt points the z axis away from a target instead of towards it??
There is a much better way, but I am in a real hurry right now and my brain is not working yet so…
var direction = transform.position - target.transform.position;
That code creates a direction vector pointing from the target to you (so reverse LookAt()), then you apply it to your rotation how you need.
Hope that’s what you needed.
-Jeremy
Oh, btw, you would also use;
var rotation = Quaternion.LookRotation(direction.normalized);
To apply the direction vector.
(There is a much much easier way, so wait on this until someone else says something)
-Jeremy
var target : GameObject;
function Update()
{
transform.rotation = Quaternion.FromToRotation(Vector3.forward, (transform.position - target.transform.position).normalized);
}
untested! basically what jeremy is saying…
sweet, thanks alot guys