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.
53 lines
1.1 KiB
53 lines
1.1 KiB
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.Events;
|
|
|
|
[ExecuteInEditMode]
|
|
public class Waypoint : MonoBehaviour
|
|
{
|
|
|
|
|
|
[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);
|
|
|
|
public static event WaypointReached OnWaypointReached;
|
|
|
|
public delegate void SwapModelOnReachingWaypoint(string modelName);
|
|
|
|
public static event SwapModelOnReachingWaypoint SwapModelOnWaypointReached;
|
|
|
|
private void OnEnable()
|
|
{
|
|
m_WaypointPosition = this.transform;
|
|
}
|
|
|
|
void OnTriggerEnter(Collider other)
|
|
{
|
|
if (other.transform.CompareTag("agent") && !m_Touched)
|
|
{
|
|
if (OnWaypointReached != null)
|
|
{
|
|
m_Touched = true;
|
|
OnWaypointReached(m_Index);
|
|
|
|
if (!string.IsNullOrEmpty(m_ModelName))
|
|
{
|
|
SwapModelOnWaypointReached(m_ModelName);
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
|