using System.Collections; using System.Collections.Generic; using Fallencake.Tools; using UnityEngine; public class WoodenSwitch : MonoBehaviour{ public GameObject exitBeam; // The exit beam that blocks the path private bool isClosed = true; // Seeing if the beam is still there // Update is called once per frame void Update(){ // If the switch is pressed, destroy the beam if (!isClosed){ Destroy(exitBeam); } } private void OnCollisionEnter2D(Collision2D other) { if (other.gameObject.CompareTag("Player")){ // If the switch is stepped on, set whether the beam is closed or not to false isClosed = false; } } }