Answers for "Help with rotation code."
http://answers.unity.com/questions/786666/help-with-rotation-code.html
The latest answers for the question "Help with rotation code."Answer by flaviusxvii
http://answers.unity.com/answers/786710/view.html
this.transform.rotation.z <-- Unless you are a mathematical genius this is not what you expect. That's the z component of a Quaternion. use this.transform.rotation.eulerAngles.z to get the z rotation.Sun, 07 Sep 2014 19:11:58 GMTflaviusxviiAnswer by zharik86
http://answers.unity.com/answers/786695/view.html
Your problem consists that you misunderstand Quaternion. See docs. [Quaternion][1] is the four-component vector which each value is in the range from 0 to 1. And eulerAngles is the three-component vector which each value is in the range from 0 to 360. So, to rotate, to use Quaternion.Euler() better:
private var rotateZ: float = 0.0; //create global variable for save current rotation
function myFunc() { //or maybe this code in function Update()
var dx = this.transform.position.x - player.transform.position.x;
var dy = this.transform.position.y - player.transform.position.y;
var radians = Mathf.Atan2(dy,dx);
var angle = radians * 180.0/ Mathf.PI; //I dont't know what is variable lookangle, but maybe you want translate radians to degree
rotateZ = Mathf.LerpAngle(rotateZ, angle, 5.0*Time.deltaTime);
this.transform.rotation = Quaternion.Euler(0, 0, rotateZ);
}
I hope that it will help you.
[1]: http://docs.unity3d.com/ScriptReference/Quaternion.htmlSun, 07 Sep 2014 18:54:46 GMTzharik86