How do I get the AI to target the prefab object when it spawns? (Unity)

When I spawn the object through Unity’s Network Manager, how do I get the AI to target the object and go to it? The scripts used are the Seeker and the AI Path.

You need a script attached to your AI that determines when it should set or change targets.

For example,

AIPath patherScript;
Transform myTarget;

void Start(){
patherScript = this.GetComponent< AIPath>();
}

void Update (){
if (patherScript.target != myTarget){
patherScript.target = myTarget;
patherScript.SearchPath();}
}
}

1 Like