Geek Culture
Published in

Geek Culture

2.5D Platformer: Setting up the Elevator, Part 4

In this final part of setting up the Elevator, I’ll have it go back up when the Player presses the “E” key a second time after boarding the Elevator.

The first thing I’ll do is change the CallElevator() method to work as a toggle instead of assigning the _goingDown value to true. I can do this by setting it to _goingDown = !_goingDown. This will switch it between true and false when the method is called.

Next, in the FixedUpdate() method, I need to set the Elevator to go back up to the Second floor if _goingDown is false. I do this by adding an else if statement.

Now the Elevator will come down and go back up with the Player.

That completes the fourth and final part of setting up the Elevator. Next, I’ll be setting up wall jumping, so make sure to check the next article.

And until next time, I wish you well on your 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