The Exit
Part of the Physics and Gameplay section of Coddy's Unity journey. Lesson 64 of 71.
Challenge
MediumFill in Exit: a pad that lets the player out once it is open.
- Add
private bool open = false;andpublic void Open(): setopen = true;, color the padColor.greenand logThe exit is open. - In
OnTriggerEnter(Collider other), whenopen && other.CompareTag("Player"), logYou escaped!and callother.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
1Rigidbody
Gravity and MassPush with AddForceJump with an ImpulseFixedUpdate for PhysicsVelocityKinematic BodiesRecap: Launch Pad4Coroutines
InvokeInvokeRepeating, CancelInvokeYour First CoroutineLoops in CoroutinesStopping CoroutinesRecap: Countdown10Project: Arena Escape
The ArenaHunters2Collisions
OnCollisionEnterWhat Did I Hit?Break on ImpactStanding on the GroundBounce and FrictionCollider ShapesRecap: Breakable WallPractice on your own: Unity playground