- Home /
AI destination not changing?
So I have a target, and AI. This was all working and suddenly stopped when I changed the target from a sphere to a cube. Not sure why. The AI has a script attached with a GameObject target. The AI will move directly to the target, but If I move the target, they will not follow. I debugged the target location and even tho the target has moved, the location is still saying it is at where it was when I clicked play.
Here is the inspector settings. 
Here is the script, nothing has been changed here from when it was working, and now that it has stopped. using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.AI;
 public class AIMovement : MonoBehaviour {
 
 
     [SerializeField]
     Transform target;
     NavMeshAgent _navMeshAgent;
     // Use this for initialization
     void Start () {
         _navMeshAgent = this.GetComponent<NavMeshAgent>();
     }
     
     void Update(){
         if(!target){
             Debug.Log("No target found.");
         }else{
             _navMeshAgent.SetDestination(target.transform.position);
             Debug.Log("Target Position: " +target.transform.position);
         }
     }
 
 }
 
Your answer
 
 
             Follow this Question
Related Questions
NavMeshAgent not fully reaching destination, thus it won't delete itself when it gets there 1 Answer
Get NavMeshAgents (Enemies) to not bunch up together 3 Answers
How would I simulate a rectangular Nav Mesh Agent? 0 Answers
Unity Navagation Ground Mapping 1 Answer
Put (Instantiate) Gameobject along or accross a path Unity 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                