Menu
CoddyTech

The Exit

Part of the Physics and Gameplay section of Coddy's Unity journey. Lesson 64 of 71.

challenge icon

Challenge

Medium

Fill in Exit: a pad that lets the player out once it is open.

  1. Add private bool open = false; and public void Open(): set open = true;, color the pad Color.green and log The exit is open.
  2. In OnTriggerEnter(Collider other), when open && other.CompareTag("Player"), log You escaped! and call other.gameObject.SetActive(false);.

Press Play: the exit stays red for now. Then Check.

Try it yourself

using UnityEngine;

public class Exit : MonoBehaviour
{
    // A later lesson fills this in: the way out, open after the last wave.
}

All lessons in Physics and Gameplay

Practice on your own: Unity playground