The Power of 3D UI

Using 3D UI Elements, Control the Excavator’s Movement, Rotation, and Bucket/Arm

Jordan T Kay
4 min readMay 8, 2024

The final stage of the Pentathlon is to destroy an old building using an excavator. To accomplish this, we need to put a system in place to allow the player to control the excavator.

This is the scene….

And this is the schematics the controls should follow…

UI PREFABS

Using Unity’s new XR Interaction Toolkit Sample project, we were able to import the following 3D UI prefabs, all of which includes their own variation of the Simple XR Interactor.

JOYSTICK

SLIDER

BUTTON

CONFIGURING UI PREFABS

BUTTON

OBJECTIVE: Power on/off the excavator

We want this to be the ignition switch to our excavator, so we want the following functions to be implemented…

  • We want the button to be able to be toggled, thus allowing it to stay activated
  • When the button is pressed, the excavator script should be enabled (allowing the other UI components to control the excavator) and have the exhaust smoke particle effect play
  • When the button is released, the excavator script should be disabled (which will have the player not be able to control the excavator with the other UI components) and have the exhaust smoke particle effect stop

RIGHT JOYSTICK

OBJECTIVE: Control the tracks of the excavator

We want the right joystick to be the “steering wheel” of the excavator, as well as controlling the forward/backward movement. This means we want the following functions to be implemented…

  • When the player moves the joystick left/right the tracks will rotate the excavator left/right
  • When the player moves the joystick forward/backwards the tracks will rotate the excavator forward/backward

LEFT JOYSTICK

OBJECTIVE: Control the cab rotation and the position of the arm

We want the left joystick to move the arm up/down and rotate the cab left/right. To accomplish this, we need to implement the following functions…

  • When the player moves the joystick left/right the cab will rotate the left/right
  • When the player moves the joystick forward/backwards the arm will move up/down

SLIDER

OBJECTIVE: Move the bucket of the excavator up/down

As I developed the slider, it did not feel nor look correct. So I am opting for a slight change — instead of using a slider for the bucket, we are going to use another joystick. But, since we have no reason for a function to be executed along the X-Axis we are going to set the joystick to only work front/back.

DESTROY THE BUILDING!

--

--

Jordan T Kay

Join my journey into game development with Unity. Learning all I can to produce quality games. 🚀