- Home /
Rotation stopping before correctly reaching y level
Hello, I am making a space game.One of the main camera controls in the game is the ability t right click on something and then be sent to it, however, the rotation stops short meaning you often end up under or above where you should be. Here is the script that handles rotation.
if (rotateToTarget == true)
{
Vector3 targetDirection = (Target.position - myTransform.position).normalized;
Quaternion targetRotation = Quaternion.LookRotation(targetDirection);
deltaAngle = Quaternion.Angle(myTransform.rotation, targetRotation);
myTransform.rotation = Quaternion.Slerp(
myTransform.rotation,
targetRotation,
TurnSpeed * Time.deltaTime / deltaAngle
);
if(deltaAngle <= 0)
{
rotateToTarget = false;
moveToTarget = true;
}
}
rotateToTarget is not made false by any other script and delta angle always ends up being zero so the script is not being interrupted. Any and all ideas are appreciated.
Your answer
Follow this Question
Related Questions
Calculate rotation angle for two side of cube ( like dice ) from Quaternion.identity 0 Answers
calculating looking angle between 2 transforms 0 Answers
Look at like rotating around y axis 1 Answer
ConfigurableJoint - angular positions (rotation) problem 1 Answer
How to rotate a quad based on another object's rotation? 0 Answers