January 2018
Beginner
254 pages
6h 25m
English
Now that we've set up our AI agent, we need a way to tell it where to go. Our sample project provides a script named Target.cs that does just that.
This is a simple class that does three things:
The code is fairly straightforward. The entire class looks like this:
using UnityEngine;using UnityEngine.AI;public class Target : MonoBehaviour{ private NavMeshAgent[] navAgents; public Transform targetMarker; private void Start () { navAgents = FindObjectsOfType(typeof(NavMeshAgent)) as NavMeshAgent[]; } private void UpdateTargets ( Vector3 targetPosition ) {Read now
Unlock full access