I have a projectile that I want to home in on a moving target, and I am using Quaternion.Slert to rotate to a calculated rotation from Quaternion.LookRotation, and for some reason, my code doesn’t rotate my missile at all.
Here is my code segment:
if(targetTransform != null )
{
Debug.Log("facing target: " + targetTransform.name);
Quaternion wantedRotation = Quaternion.LookRotation(targetTransform.position-projTransform.position);
float timeToRotate = ProjTurnRadiusDegreesPerSec*Time.time;
Quaternion.Slerp(projTransform.rotation,wantedRotation,timeToRotate);
Debug.Log("distanceToTarg: " + (targetTransform.position - projTransform.position).magnitude);
}
When I test my game, the missile just moves forward (I am doing a translate outside of this that moves it forward by its thrust value). The “facing target” code prints out the correct target I am aiming at.
Another oddity, when I output the distance (as shown above), it grows very slowly. Why is this? There is obviously more distance than what is being reported, as I can look at the positions in the inspector, the distance is obviously wrong. What could this mean?
Why doesn’t the projectile turn?