Hi,
how can i freeze the rotation to an axis so that the character does not bend over to look at his target?
I have tried to copy the character’s rotation in y or z, but the result is not what i would expect:
This is the wrong result : (the character is bending over)
42
42
var rot : Quaternion = Quaternion.identity;
//in UPDATE
var dir : Vector3 = vectorEndPoint - thisTransform.position; //vectorEndPoint = the ball; thisTransform = the character
rot = Quaternion.LookRotation( dir );
rot.eulerAngles.z = thisTransform.rotation.z; //y or z
thisTransform.rotation = Quaternion.Slerp( thisTransform.rotation, rot, Time.deltaTime * 5 );
//or this way :
var dir : Vector3 = vectorEndPoint - thisTransform.position;
//TEST
thisTransform.rotation = Quaternion.Slerp( thisTransform.rotation, rot, Time.deltaTime * 5 );
thisTransform.localEulerAngles = new Vector3(thisTransform.localEulerAngles.x, 0, thisTransform.localEulerAngles.z);
Would you know you to achieve this?
Thanks
SOLUTION:
var newRotation = Quaternion.LookRotation( dir );
newRotation.x = 0.0;
newRotation.z = 0.0;
thisTransform.rotation = Quaternion.Slerp( thisTransform.rotation, newRotation, Time.deltaTime * 5 );