This repository has been archived on 2024-08-16. You can view files and clone it, but cannot push or open issues or pull requests.
sota/RunningLateGame/Assets/Scripts/AerialFaithLandingTrigger.cs

41 lines
1.3 KiB
C#
Raw Normal View History

/*
* author: mark joshwel
* date: 10/8/2024
* description: trigger to detect if the player landed in a specific area
*/
using System;
using UnityEngine;
/// <summary>
/// detection behaviour class
/// </summary>
public class AerialFaithLandingTrigger : MonoBehaviour
{
/// <summary>
/// the trigger that detects if the player has jumped out of the play area
/// </summary>
[SerializeField] private AerialFaithLeapTrigger linkedLeapTrigger;
/// <summary>
/// check if linkedLeapTrigger is set
/// </summary>
/// <exception cref="NullReferenceException">consequential exception</exception>
private void Awake()
{
if (linkedLeapTrigger == null)
throw new NullReferenceException("AerialFaithLandingTrigger: linkedLeapTrigger is not set");
}
/// <summary>
/// detect if player has entered the trigger
/// </summary>
/// <param name="other">colliding game object</param>
private void OnTriggerEnter(Collider other)
{
// Debug.Log($"AerialFaithLandingTrigger: was hit by object with tag {other.tag}");
if (!other.CompareTag("Player") || !linkedLeapTrigger.isPlayerInAir) return;
Debug.Log("AerialFaithLandingTrigger: player landed");
linkedLeapTrigger.isPlayerInAir = false;
}
}