You are on page 1of 1

var target: Transform;

static var Qangle: float;

function Update () {

//what direct the object points change the -Vector3 to Vector3 if pointing in
wrong direction
var newRotation = Quaternion.LookRotation(transform.position - target.position,
-Vector3.up);
var orienttransform = transform.position.x;
var orienttarget = target.position.x;

//Example how to lookup an angle (see printout on console for results)


Qangle = transform.eulerAngles.z;

//if player jumps over object it points the other way


if (orienttransform > orienttarget){
newRotation = Quaternion.LookRotation(transform.position - target.position,
Vector3.up);}

// zeros out x and y making it easy to use in side scroller


newRotation.x = 0.0;
newRotation.y = 0.0;

//flip object around it face if you jump over object


transform.rotation = Quaternion.Lerp(transform.rotation, newRotation,
Time.deltaTime *8);

print(Qangle);