Unity/C# Challenge 50: The Elevator Problem Pt 2.

Alec Oney
Nov 18, 2021

Challenge: Make our elevator require coins to operate.

Currently, our elevator light changes color to green when we get near it and press “E”. Before we update our script to actually move the elevator, we want to expand our requirements to include a coin limit. To start, we modify our elevator panel script to include a private int to cover our required coins (8, in this case), then modify our player script to include:

This will provide an int matching the number of coins that the player has. We can then utilize this number by modifying our elevator panel script:

Where, now, when the player gets in range of the elevator AND has 8 or more coins, then the elevator light will change. Next, we will start to work on moving the elevator.

--

--