Geek Culture
Published in

Geek Culture

2.5D Platformer: Setting up the Elevator, Part 2

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.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store