Requiring the Player to get enough coins before it can use the Elevator Panel in Unity
This time around, we only want the Player to be able to use the panel if it has enough coins.
Since the Elevator panel needs access to how many coins that the Player has, we need to provide the method from the Player publicly:
From the ElevatorPanel, we need to be able to set the number of coins needed to activate it. Though we added a default option, because of [SerializeField], this value can still be edited in the Game editor:
As you can see, there are three conditions to be able to enable the Elevator.
- The collider is a Player
- The key pressed is E
- The players coins are greater than or equal the required coins
Now, this feature is implemented: