read
3 Actor AI
- Find source project Tutorial_3_AI in Shooter
Add AI
Add AI to enemies, mainly path finding. Bake navigation first.
Add NavMeshAgent to AI models.
Use script to give them destination.
To avoid polluting complete game script, all script class should be put inside namespace Tutorial
.
public Transform destPoint;
private NavMeshAgent nav;
void Awake()
{
nav = GetComponent<UnityEngine.AI.NavMeshAgent>();
if (!nav)
return;
Init();
}
public void Init()
{
nav.SetDestination(destPoint.position); // set nav destination
}
Next turoial please click Enemy patrols.
More details, please visit the project here