Hot answers tagged rotation
Use Transform.TransformDirection() method where Transform is your player transform. // Calculate the x-axis relative to the camera camera = Camera.main.transform; cameraRelativeRight = camera.TransformDirection (Vector3.right); // Apply a force relative to the camera's x-axis rigidbody.AddForce (cameraRelativeRight * 10);
You can use Quaternions instead of Euler Angles to solve this. transform.rotation = Quaternion.Lerp(transform.rotation, Quaternion.Euler(rotationDestination), Time.deltaTime * rotationSpeed); If you want to test distance still, you can use... if(Quaternion.Angle(transform.rotation, Quaternion.Euler(rotationDestination)) > 0.2f) I'd suggest you ...
I'm not sure exactly how the code works and this obviously won't work if any methods require an angle between -180 and 180 degrees, but rather than setting the target rotation to -179, could you instead set it to 181 degrees? To my (very limited) understanding that is the same angle as -179 degrees.
Only top voted, non community-wiki answers of a minimum length are eligible