My Zombie AI is Not Working...

I watched 2 youtube videos…i will attach the codes here…but still none of them are working for me…(note- it is working for the youtubers) pls someone help as soon as possible asap…
script 1

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;

public class EnemyMovement2 : MonoBehaviour
{
    UnityEngine.AI.NavMeshAgent nm;
    public Transform target;

    public enum AIState { idle,chasing};
    public AIState aiState = AIState.idle;
    void Start()
    {
        nm = GetComponent<UnityEngine.AI.NavMeshAgent>();
    }

    void Update()
    {

    }
    IEnumerator Think()
    {
        while (true)
        {
            nm.SetDestination(target.position);
            yield return new WaitForSeconds(1f);
        }
    }
}

script2

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;

public class EnemyMovement : MonoBehaviour
{
    public float fov = 120f;
    public Transform target;
    public bool inSight;
    public float AwakeDistance = 200f;
    public bool AwareOFPlayer;
    public NavMeshAgent enemyAgent;




    private void update(){
        float PlayerDistance = Vector3.Distance(target.position, transform.position);
        Vector3 playerDirection = (target.position - transform.position);
        float playerAngle = Vector3.Angle(transform.forward, playerDirection);
        if(playerAngle <= fov / 2f){
            inSight = true;
            Debug.Log("PlayerinSight");
        }else{
            inSight = false;
        }
        if(inSight == true && PlayerDistance <= AwakeDistance){
            AwareOFPlayer = true;
        }
        if (AwareOFPlayer == true)
        {
            enemyAgent.SetDestination(target.position);
        }

    }

}

If you want help with your code, you need to get very specific with what the problem is. Just saying it isn’t working without providing any information as to what that means, usually results in no help. Not because people don’t want to help, but because people can’t help.

1 Like

the thing is that my zombie is not moving closer to my player even after adding the script…it just stays there doing the walk animation at the same place(not even moving,right at the same place)…now can u pls help!!!
ASAP