Sitemap

Creating Elevator

5 min readAug 10, 2025

In the first step, create a script called Elevator and attach it to the elevator Platform. Add an Interactable script and add a sphere Collider whose needs isTrigger to be true, then make sure to add a UITransform.

Go Inside the Elevator script, create the following variables.

Press enter or click to view image in full size

Go to the Update method, check if isCalled is true, then store the distance between elevatorPlatform and elevatorLevels using nextLevelIndex as the array value indexes. Then we move the elevator using Vector3 dot MoveForward, passing our position(elevator platform) and elevatorLevels.

Press enter or click to view image in full size

To be able to move the elevator to the next level, we need to make sure we have reached the destination. We do that by checking if the distance is equal to 0, then set isCalled to false.

Press enter or click to view image in full size

Then we increment nextLevelIndex, but it's very important to avoid the error of the array being out of bounds and being able to go back to the first level. We check if the nextLevelIndex is equal to elevatorLevels. dot length, then set the nextLevelIndex to zero.

Press enter or click to view image in full size

Now, go to the Scene, create an empty object for every floor where the elevator needs to move to.

Note: If you dont have a specific position, place the elevator box, duplicate it, remove all components, just leave it as empty, and do the rest of the position you want this elevator to reach.

Press enter or click to view image in full size

Now drag and drop those empty objects to the elevatorLevels array. When the game starts player sets the nextLevelIndex to make sure the elevator moves to that destination.

Note: Element Zero is where the elevator is stationary ,so I want to put nextLevelIndex to 1 or 2 if I want to allow it to move down or up.

Go to Interact and check if isPoweredUp is true, then set isCalled is true. This is called when the player presses E when it is detected by the elevator collider.

Since our elevator is powereUp by PowerCore, go to Activate and set isPoweredUp equal to the isActivated parameter. This method is called by PowerReceiver when sufficient powerCoreLevel is matched with the requiredPowerLevel by PowerReceiver.

Note: To understand this, go back to how I design my puzzle to access the elevator article.

https://medium.com/@suleimanabdullah/creating-a-puzzle-for-accessing-the-elevator-d8559e0f034d

If we play like this, we will have issues with the CharacterControl physics system, camera jittering, and pulling in and out. This is due to the CinemachineThirdPersonFollow setup.

Solution: Create an empty object inside the elevator platform and a new script called ChangeParentTrigger.Add a box Collider and edit to touch the elevatorPlatform the floor, and adjust the height a little bit than the player’s height.

Press enter or click to view image in full size

Go to ChangeParentTrigger, create the following variables.

Press enter or click to view image in full size

Go to the Start method and get the Cinemachine3RdPersonFollow component, then store its default damping and camera distance. But also, we want to define the elevator damping and elevatorVcamDistance.

Note: For ElevatorVcamDistance, we give the designer the ability to set the value in the inspector.

Press enter or click to view image in full size

Now add OnTriggerEnter, when the player enters the trigger, we set the player's parent to the elevator platform to prevent the player from moving. This may be more visible if you have a moving platform.

But also, we want to change the damping and cameraDistance of Cinemachine3RdPersonFollow to elevatorVcamDamping and elevatorVcamDistance.

Press enter or click to view image in full size

When the player exits the elevator, we want to reset to the default setting.

Press enter or click to view image in full size

Damping is usually used to make the camera rest or catch the target, so by putting y-damping to zero, it will remove the camera jittering. The camera distance is usually its distance from the player's arm to the camera. By setting the camera distance low value, it will remove the zoom in and out, this is due to player movement, and the camera tries to rest at the default rest distance.

Dont forget to drag and drop Cinemachinge there, below you will see my camera, which needs to be dragged to the VirtualCam

This is how I create an elevator system.

Press enter or click to view image in full size

See you at the next one. Feel free to comment with any suggestions

--

--

Suleiman Abdullah
Suleiman Abdullah

Written by Suleiman Abdullah

My name is Suleiman Abdullah. I learn game development and share what I learn by writing articles. :https://ko-fi.com/suleimanabdullah

No responses yet