I can’t get this AI of mine to look at the direction of a collision smoothly. He snaps at it.
My usual code that I have used for the AI following does not work. It gives no errors but the AI does not detect the bullet collision or simply can’t turn.
Code:
// This is the code that works but I cannot get to slerp or be smooth.
void Searching(){
transform.rotation = Quaternion.LookRotation(targetDirection);
}
// This is where the targetDirection comes from.
void OnTriggerEnter(Collider colp){
targetDirection = colp.transform.postion-transform.postion;
} }
A Slerp, like a Lerp is not performed in one function. You must attend to the function frame after frame gradually changing the value of t. Note that t ONLY works between 0 and 1. So when navSpeed * Time.deltaTime is Greater than 1 the Slerp will be at its destination.
What is the value of navSpeed?
Each frame your transform.rotation is updated to be the Current Position of the result of the Slerp. This late at night Im not sure but my pulverised brain is telling me you’ll slow down as you get closer? I could be wrong