Puzzles — Elevator

Daniele Quero, PhD
Nerd For Tech
Published in
3 min readOct 28, 2021

--

Objective: create the first puzzle with an elevator call and rise

With this tutorial I want to show how simple puzzles can be implemented in a 2.5D platform. I prepared the environment in advance, and I plan to put 3 puzzles. The first one will involve an elevator.

The elevator is the grey cluster of objects. It will be called through the panel below, the one having a red led. The idea is to make the led green when the player is near the panel and it is possible to call the elevator, the call will be performed via E key press.

The elevator can be called only if the player has collected enough coins.

OnTriggerStay() works somehow like Update() performing in loop all the instructions inside. We check the player purse for the coins, if enough we turn the led green and get ready for the call (E key). An UI text is updated to tell the player a message whether good or bad, according to the coin amount.

When exiting the trigger, we turn the led red again and clear the text.

The elevator will boast two script: the first is the moving platform one, the second will be a controller, since we don’t need the elevator to go up and down like a moving platform.

So, as a start, the elevator will have the MovingPlatform component disabled, but filled with the only down-position waypoint. The CallElevator() method will just enable the script and the object cannot help but go down. But since there is just one waypoint, down, the elevator will not loop between waypoints!

Upon entering the elevator, and ulterior trigger properly placed, we reset the moving platform script changing its only waypoint to up position and setting the speed: the elevator will go up and never go back!

--

--

Daniele Quero, PhD
Nerd For Tech

A professional developer with passion for game developing and skill-growing. A former Nuclear Physics Researcher who changed his life to pursue his dreams