After a one-week battle of reading the other topics on the forum and numerous tries to alter my code I need your help with defining a proper rotation logic. My problem is that, at a certain angle, the objects forget that they should rotate and stop in place until the player moves near them at a specific angle, as can be seen in the video.
http://www.megafileupload.com/en/file/556113/Rotation-Flip-wmv.html
I know the answer is probably painfully obvious, but I just can’t understand how to do it and I’m just too short a unityscript coder to grasp the Quaternion and eulerAngles, so if you could at least pinpoint in which direction I should go to understand this. I don’t want to copy others script because it will put me nowhere in the long run.
Here is the code which I am currently trying to work:
var rotation = Quaternion.LookRotation(astTarget.position - astSelf.position);
astSelf.rotation = Quaternion.Slerp (astSelf.rotation, rotation, astSmoTur * Time.deltaTime);
astSelf.rotation.y = 0;
astSelf.rotation.x = 0;
And here is the additional code attached to the object:
function Update()
var newSpeed = asteroidSpeed * Time.deltaTime;
transform.position = Vector3.MoveTowards (transform.position, asteroidTarget.position, newSpeed);
transform.Translate (Vector3.right * newSpeed);