2.5D Platformer: Setting up the Elevator, Part 2

Brian Branch
Geek Culture
Published in
2 min readOct 4, 2021

In this article, I continue the setup for the elevator in the 2.5D Platformer. In the previous article, I went over having the Player press the elevator button when they are in range and changing the button when pressed.

This time I’ll be adding an additional requirement for the Player to have collected 8 “coins” for the button to work.

This is actually fairly straightforward to accomplish. But, first, I need a method on the Player script that will return how many coins the Player has.

In the ElevatorPanel script, I need to get a reference to the Player script using GetComponent.

Then when I check if the “E” key has been pressed, I add an additional check to see if the return from calling the above method is greater than or equal to 8.

Now the Player can only press the Elevator button if they have at least 8 coins.

This was a pretty short one. In the next article, I’ll actually set up the functionality to call the elevator and have it move down to the Player.

Until then, I wish you well on your own coding journey.

--

--