About the Suspicious Behaviour

Hello Sam, regarding this section I would like to add something I did for myself just for learn something new. I did follow your idea regarding the suspicious and come back to guard for enemy but I not very like the fact that the guard back on position turn on the wrong rotation, so I did little add on to your code:
On the AIController added as follow

        Quaternion originalRotation;
        float rotateSpeed = 5f;    

On the Start:

       originalRotation = transform.rotation;

And on the GuardBehaviour itself

            // y value can be different from start coz we drop down enemy to a custom Terrain
            // If the guard get back to the guard position, turn back on old rotation
            if (guardPosition.x == transform.position.x && guardPosition.z == transform.position.z)
            {
                if (originalRotation != transform.rotation)
                {
                    transform.rotation = Quaternion.Lerp(transform.rotation, originalRotation, Time.deltaTime * rotateSpeed);
                    Debug.Log(gameObject.name + " ROTATE BACK TO " + transform.rotation.eulerAngles.ToString());
                }
            }

Hope it will be usefull for someone :slight_smile:

1 Like

Privacy & Terms