using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;
public class SWATwalking : StateMachineBehaviour
{
float SWATwalkingtime;
NavMeshAgent SWATagent01;
private GameObject[] SWATwaypointsAC;
// OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
SWATwalkingtime = 0f;
if(SWATwaypointsAC == null)
{
SWATwaypointsAC = animator.gameObject.GetComponent<SWATwaypoints>().SWATwaypoints01;
}
SWATagent01 = animator.GetComponent<NavMeshAgent>();
SWATagent01.SetDestination(SWATwaypointsAC[Random.Range(0, SWATwaypointsAC.Length)].transform.position);
}
// OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
SWATwalkingtime += Time.deltaTime;
if (SWATwalkingtime >= 5)
{
animator.SetBool("IsWalking", false);
}
}
}
line 26 is what i need to change, enemy patrols randomly between the four objects in the ray but i want the enemy to move between points in order eg 0, 1, 2, 3 and not randomly but idk how to set the range ![]()