started building out level
Signed-off-by: sdqhome\caleb <caleb@sdqhome.co.uk>
This commit is contained in:
38
Assets/Scripts/Quests/LocationObjectiveTrigger.cs
Normal file
38
Assets/Scripts/Quests/LocationObjectiveTrigger.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Quests
|
||||
{
|
||||
[RequireComponent(typeof(Collider))]
|
||||
public class LocationObjectiveTrigger : MonoBehaviour
|
||||
{
|
||||
[Tooltip("The Target ID of the ReachLocation objective.")]
|
||||
[SerializeField] private string locationID;
|
||||
|
||||
[Tooltip("Only trigger when the collider tagged with this tag enters. Default: 'Player'")]
|
||||
[SerializeField] private string playerTag = "Player";
|
||||
|
||||
[Tooltip("If true, this trigger object disables itself after firing once.")]
|
||||
[SerializeField] private bool triggerOnce = true;
|
||||
|
||||
private bool hasTriggered = false;
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
if (hasTriggered && triggerOnce) return;
|
||||
|
||||
if (other.CompareTag(playerTag))
|
||||
{
|
||||
if (QuestManager.Instance != null)
|
||||
{
|
||||
QuestManager.Instance.ReportLocationReached(locationID);
|
||||
hasTriggered = true;
|
||||
|
||||
if (triggerOnce)
|
||||
{
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user