FiE-Game/Assets/Cinema Director/Cutscene Items/Actor Items/Navigation/SetDestinationEvent.cs
2023-07-27 00:47:00 +05:00

29 lines
889 B
C#

using UnityEngine;
using UnityEngine.AI;
namespace CinemaDirector
{
/// <summary>
/// An event for setting a navigation destination.
/// Only executes in runtime. Not reversable.
/// </summary>
[CutsceneItemAttribute("Navigation", "Set Destination", CutsceneItemGenre.ActorItem)]
public class SetDestinationEvent : CinemaActorEvent
{
// The destination target
public Vector3 target;
/// <summary>
/// Trigger this event and set a new destination.
/// </summary>
/// <param name="actor">The actor with a NavMeshAgent to set a new destination for.</param>
public override void Trigger(GameObject actor)
{
NavMeshAgent agent = actor.GetComponent<NavMeshAgent>();
if (agent != null)
{
agent.SetDestination(target);
}
}
}
}