Enemy AI chasing you

Hi, there is lots of this information in unity and I have been researching it tonight. I didn’t want to copy and past code and attach targets but instead write it line by line so I understand what is happening and test as I go. The one area I got stuck in was how to make the zombie turn slower? When I try and run around behind it, it turns at the same pace I do.

My Update() code.

void Update () {
        Vector3 sPoint = new Vector3(0f,0f,speed); // create a slow speed moving towards target
        transform.Translate(sPoint); // This moves zombie the script is attached to.

        // bellow uses the player X and Z to point at the player. The Y is self, so it won't rotate in that axis
        Vector3 targetPostition = new Vector3( target.position.x,  transform.position.y, target.position.z ) ;
        transform.LookAt( targetPostition ); // this function tells the zombie to look at the player.

I believe this has to do with the Quaternion.Slerp() but I can’t seem to wrap my head around this idea, can anyone shed some light on that subject?

Thank you.

Well, the LookAt method is instantaneous, basically. That’s something you’d maybe use for the eyes/head, but not the whole body, for instance.

For that kind of rotation, check into:

That’ll let you set a speed(step) for your rotation.

If you dig around a bit, you’ll see that the way most people seem to use Lerp and Slerp is not for what they are intended.

Lentaq, thank you. This starts to put me on the right track.