Files
BABA_YAGA/Assets/Invector-3rdPersonController/Basic Locomotion/Scripts/Generic/Triggers/vCheckpointExample.cs

37 lines
1000 B
C#
Raw Normal View History

2026-05-30 09:16:35 +07:00
using Invector.vCharacterController;
using UnityEngine;
using UnityEngine.Events;
namespace Invector.Utils
{
/// <summary>
/// Simple Checkpoint Example, works by updating the vGameController SpawnPoint to this transform position/rotation.
/// </summary>
[RequireComponent(typeof(BoxCollider))]
public class vCheckpointExample : MonoBehaviour
{
vGameController gm;
public UnityEvent onTriggerEnter;
void Start()
{
gm = GetComponentInParent<vGameController>();
this.GetComponent<BoxCollider>().isTrigger = true;
}
private void OnTriggerEnter(Collider other)
{
if (other.gameObject.CompareTag("Player"))
{
vHUDController.instance.ShowText("Checkpoint reached!");
gm.spawnPoint = this.gameObject.transform;
onTriggerEnter.Invoke();
this.gameObject.SetActive(false);
}
}
}
}