Hey guys I’m trying to use Quaternion.lookrotation to get an object to rotate towards a target, it then moves in the forward direction, however it is returning bizarre results. I’ll post the code and some example figures:
//movement direction
Vector3 dir = position - myTransform.position;
Debug.Log ("Dir: " + dir);
// Rotate towards the target
myTransform.rotation = Quaternion.Slerp(myTransform.rotation,
Quaternion.LookRotation(dir), rotationSpeed * Time.deltaTime);
Debug.Log ("target rotation: " +Quaternion.LookRotation(dir));
Debug.Log ("mytransform.rotation: " + myTransform.rotation);
ok so here lies my confusion. In a test run i did, the vector3 Dir came out as
(0.5, 0.0, 0.0)… then using quaternion lookrotation(dir) comes out as (0.0, 0.7, 0.0, 0.7)… I can’t even begin to understand where it got that from? As always any help is greatly appreciated.