Portal.cs
Description
This script is used to check when the player has finished the level.
Script
using UnityEngine;
using UnityEngine.SceneManagement;
namespace Environment
{
public class Portal : MonoBehaviour
{
private void OnTriggerEnter(Collider other)
{
if (!other.transform.parent.gameObject.CompareTag("Player")) return;
SceneManager.LoadScene("winScene");
}
private void OnTriggerStay(Collider other)
{
if (!other.transform.parent.gameObject.CompareTag("Player")) return;
SceneManager.LoadScene("winScene");
}
}
}
Private Methods
- OnTriggerEnter()
Checks if the collided object is the player. If it is, then load the win scene.
- OnTriggerStay()
Checks if the collided object is the player. If it is, then load the win scene.
Last modified: 30 April 2024