You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1008 B
52 lines
1008 B
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using Unity.VisualScripting;
|
|
using UnityEngine;
|
|
using UnityEngine.Events;
|
|
|
|
[ExecuteInEditMode]
|
|
public class Waypoint : MonoBehaviour
|
|
{
|
|
public bool m_StartingPosition;
|
|
|
|
[HideInInspector]
|
|
public Transform m_WaypointPosition;
|
|
|
|
public float m_WaitTime;
|
|
|
|
public string m_ModelName;
|
|
|
|
public float m_Index;
|
|
|
|
public bool m_Touched;
|
|
|
|
|
|
|
|
public delegate void WaypointReached(float index, string modelName);
|
|
|
|
public static event WaypointReached OnWaypointReached;
|
|
|
|
private void OnEnable()
|
|
{
|
|
m_WaypointPosition = this.transform;
|
|
}
|
|
|
|
|
|
void OnTriggerEnter(Collider other)
|
|
{
|
|
if (other.transform.CompareTag("agent"))
|
|
{
|
|
CheckWaypoint();
|
|
}
|
|
}
|
|
|
|
private void CheckWaypoint()
|
|
{
|
|
if (OnWaypointReached != null && !m_Touched)
|
|
{
|
|
m_Touched = true;
|
|
OnWaypointReached(m_Index, m_ModelName);
|
|
}
|
|
}
|
|
}
|
|
|