Hi, my code was working great untill a moment i did not notice it does'nt. I was making some animations and now i have no clue why the object is not rotating! Code (CSharp): public void FollowMouse(Vector3 mouseXY) { mouseXY = GetWorldPositionOnPlane(Input.mousePosition, 0); Vector3 vectorToTarget = mouseXY - transform.position; float angle = Mathf.Atan2(vectorToTarget.y*-1, vectorToTarget.x*-1) * Mathf.Rad2Deg; Quaternion q = Quaternion.AngleAxis(angle, Vector3.forward); transform.rotation = Quaternion.Slerp(transform.rotation, q, Time.deltaTime * 15); }
Did you insert some debug messages to see if the method is being called and if the values are what you expect them to be? @Antypodish beat me to it. lol.
I print the transform.rotation and this is what i get: What else could it be? I checked the animation and i did'nt touch the Z axis
If your object don't rotate, then it means you override its rotation somewhere else. Or transformation.
Yea i know, i have just 4 scripts and only 1 affect my player to rotate. So i am kinda certain that the problem is not in the script. It has any connection to the animator. if i put the animator on Animate Physics so it works but not as before. Any ideas?
I solved the problem but i don't know the reason :\ I just made a new Animator Controller with the same animations and it worked. Thanks for the help!