August 2018
Beginner
334 pages
10h 19m
English
We will create a patrol behavior component to be used along with a NavMeshAgent component:
using UnityEngine;using UnityEngine.AI;[RequireComponent(typeof(NavMeshAgent))]public class NMPatrol : MonoBehaviour{ // next steps}
public float pointDistance = 0.5f;public Transform[] patrolPoints;private int currentPoint = 0;private NavMeshAgent agent;
private int FindClosestPoint(){ // next step}
int index = -1;float distance = Mathf.Infinity;int i;Vector3 agentPosition = transform.position;Vector3 ...
Read now
Unlock full access