Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.AI;
- public class IA : MonoBehaviour
- {
- NavMeshAgent a;
- public GameObject[] waypoints;
- int waypointn = 0;
- // Start is called before the first frame update
- void Start()
- {
- a = GetComponent<NavMeshAgent>();
- }
- // Update is called once per frame
- void Update()
- {
- a.SetDestination(waypoints[waypointn].transform.position);
- }
- private void OnTriggerEnter(Collider other)
- {
- if (waypointn + 1 == waypoints.Length) {
- waypointn = 0;
- } else {
- waypointn++;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement