2.5D Platformer — #7 Create an Elevator In Unity
Objective: Build the first of many puzzles
Let’s give this platformer its first puzzle, which requires the player to collect a certain amount of coins to be able to call the elevator so they can move to the next level.
The Elevator feature comprises an elevator panel and the elevator.
Elevator
The elevator is made up of a few cubes and its behaviours are no different from the moving platform except that it only moves on demand when the player is within the collider and has pressed the LEFT CTRL.
Let’s look at the script.
Basically, it is set to the starting point at the start and waits for the panel to call it which then sets to move to Point B. When it arrives, once the player is within range and presses the LEFT CTRL or Fire button, it sets the next point which moves the elevator up.
Elevator Panel
The idea behind the panel is to have the player comes inside a collider and when they click the action button (LEFT CTRL), it checks that the player has collected enough coins before it changes the LED from red to green.
The panel is simply made up of two cubes and a collider that is set as a trigger.
Let’s look at the script, we have references to the LED, how many coins are required, and the elevator.
When the player is within range and it checks how many coins were collected on the player and if the amount is enough it changes the LED material colour to green and calls the elevator.
That's is all it is!
If you enjoyed reading this article give me a Clap, also if you would like to see more, “Follow” me, so you may be notified of future releases. You may also send me a message if you need any further help.
Do you have a project in mind that you need help with, I’m available!