Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Nav mesh agent dosen't move

Discussion in 'Navigation' started by hexedo, May 1, 2022.

  1. hexedo

    hexedo

    Joined:
    Apr 30, 2022
    Posts:
    1
    My nav mesh agent dosen't want to move to destination
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.AI;
    5.  
    6. public class enemyscript : MonoBehaviour
    7. {
    8.     public Transform playerObj;
    9.     protected NavMeshAgent enemyMesh;
    10.  
    11.  
    12.  
    13.     // Start is called before the first frame update
    14.  
    15.     void Start()
    16.     {
    17.         enemyMesh = GetComponent<NavMeshAgent>();
    18.     }
    19.  
    20.     // Update is called once per frame
    21.     void Update()
    22.     {
    23.         enemyMesh.SetDestination(playerObj.position);
    24.     }
    25. }
    yomum.png