Hello everyone,
i’m using a little patrolling script that makes my player with a navmeshagent to visit different empty objects in my scene. In my animator, i only have my Walking animation.
Here is the script:
using UnityEngine;
using UnityEngine.AI;
using System.Collections;
public class Patrol : MonoBehaviour
{
public Transform[] pointsavisiter;
private int destPoint = 0;
private NavMeshAgent agent;
void Start()
{
agent = GetComponent<NavMeshAgent>();
agent.autoBraking = false;
VaAuProchainPoint();
}
void VaAuProchainPoint()
{
if (pointsavisiter.Length == 0)
return;
agent.destination = pointsavisiter[destPoint].position;
destPoint = (destPoint + 1) % pointsavisiter.Length;
}
void Update()
{
if (!agent.pathPending && agent.remainingDistance < 0.5f)
VaAuProchainPoint();
}
}
What i’d like to do is for my player to stop at each of the visited point, wait a couple of seconds, then resume patrolling? How could i do it? Also, could i use a idle animation when he is stopped?
thanks a lot for your help.