Create an Elevator In Unity

I have already created the moving platforms, our elevator starts from the same base, the only difference is that it will not move continuously but only when called.

So I will have to create a panel with a button to call the elevator. Without wasting further time let’s see what is needed.

The scene already has everything I need I just need to think about the scripts and how to handle the visual feedback.

As a first system, we are going to create the interaction with the elevator reservation button and as visual feedback, we are going to change the color of the light from red to green.

The second step is to make the elevator go down. The method of movement is the same as the moving platforms, we need a way to activate it when we press the button. With a simple bool variable most of the work is done, just make the two scripts communicate with each other.

Finally with the same button that we call the elevator we want to make sure that it can go upstairs, by enlarging the collider box of the elevator panel we manage the change of our bool variable that we created earlier.

The last thing to avoid that annoying flicker, in addition to using FixedUpdate, is advisable to make the player the child of the elevator as soon as it goes up and removes it when it goes out, using the OnTriggerEnter and OnTriggerExit methods.

project manager by day, unity developer by night