FGTE6003: Final Major Project - Timeleap Help

LargeIslandSensor.cs

Description

Checks if the player has reached the large island during the tutorial scene.

Script

using UnityEngine; namespace Tutorial { public class LargeIslandSensor : MonoBehaviour { [SerializeField] private TutorialController tutorialController; private void OnTriggerEnter(Collider other) { if (!other.transform.parent.gameObject.CompareTag("Player")) return; tutorialController.OtherIslandReached(); Destroy(gameObject); } private void OnTriggerStay(Collider other) { if (!other.transform.parent.gameObject.CompareTag("Player")) return; tutorialController.OtherIslandReached(); Destroy(gameObject); } } }

Private Methods

OnTriggerEnter()

Checks if the player has collided, if so then indicate to the tutorial controller that the player has reached the island, and if they have then destroy the sensor game object.

OnTriggerStay()

Checks if the player has collided, if so then indicate to the tutorial controller that the player has reached the island, and if they have then destroy the sensor game object.

Variables

tutorialController

The tutorial controller script.

Last modified: 30 April 2024