Game Controls Event

With a Game Controls event, you can create interactive experiences, where you control a character (that’s what we call the controlled object), by walking or flying around your scenes.

Navigate your scene and control your character with key inputs, joysticks and buttons on mobile, gravity, and collision detection.

There are many different options to customize it to the type of experience you decide to build.

Test the gameplay 🎮👇

Before moving on with the documentation, why not give the game controls a quick test below?

Use W S A D keys to move the character, SPACE to jump, and ↑↓←→ keys to move the camera.

Click the embed to focus. Open the experience in a new tab HERE.

Game Controls Video Tutorial

If you prefer to follow along with a video, we’ve made this tutorial where we go through all the details of a Game Controls event.

Adding a Game Controls Event

Here's how to add a Game Controls event to an object in your scene:

  1. Select the object that you want to control.
  2. On the Events panel, add a new event and select Game Controls from the dropdown menu.
  3. Open the Game Controls event and tweak the settings to your liking.

Adjusting Character Orientation

If your character is composed of grouped objects and you notice it is moving backwards, you’ll need to make sure it is facing towards the -Z direction.

To fix this you’ll need to select all the objects inside your main group and rotate them to face the -Z direction.

This usually means rotating all the objects inside your character group by 180º degrees.

image

Adjusting the orientation of a character so it faces the -Z direction.

Understanding the Game Controls Settings

Let's now dive deep into all the settings that can be found inside the Game Controls event, so you can adjust them to properly match the experience you’re building.

Movement

In Movement, you can define how your character will be moving around your scene.

Walk or Fly are the two movement modes of a Game Controls event.

image

Movement Mode

Walk - is used for experiences where you move on surfaces.

Fly - is used for experiences where you fly around your scene.

Auto-Orientation

When turned on, the character rotates automatically based on the direction you’re moving in.

Speed

Control the speed of position and rotation.

Delay

Control the acceleration at the Start and deceleration at the End of position and rotation.

Desktop Controls

To create unique game mechanics controls can be adjusted.

Desktop Controls is where we can define what keys are going to be used to control our character and what each of them does.

Remapping a key and changing its action.

image

Rotate By

Define how you can rotate the camera. Either by using the Mouse, the Arrow keys, or both.

Keyboard Keys

Once you select a key, you can either press another key to assign it or change the action of that key on the dropdown below.

If you’ve made too many changes, the reset button (on the top right) will let you reset to the default keys.

Here’s a list of all the behaviors and their default keys:

Default Key
Behavior
W
Move Forward (-Z)
S
Move Back (+Z)
A
Move Left (-X)
D
Move Right (+X)
Space
Jump
Rotate Up (+X)
Rotate Down (-X)
Rotate Left (+Y)
Rotate Right (-Y)
None
Move Up (+Y)
None
Move Down (-Y)

Multiple Game Controls Events

If you have multiple Game Controls events in your scene, only one of them will be the one where you can define the desktop and mobile controls.

So on every new Game Controls event, you create, you’ll see this warning, letting you know that the event you’re editing is not the main Game Controls event.

But you can always press the button below to make it the main one and edit the controls from there.

image

Touch Controls

Touch Controls lets you define the controls of your experience on touch-based devices like phones and tablets.

How touch controls look on a touch-based device.

image

Rotate By

Define how you can rotate the camera. Either by dragging on the screen or by using a joystick.

Joysticks and Buttons Position

Choose where to position the joysticks and buttons for Move, Rotate (only visible if Rotate By is set to Joystick), and Jump.

The representation you see is how they will be positioned on the device’s screen.

Offset - The space the control has from the screen edge.

Button Size - The size of each control.

Visibility - Defines if the selected control is always visible or becomes visible when interacted with.

Collision

With collision, we can define how our character will collide with everything in our scene.

Make changes to the collider on your character and tweak settings like Gravity, Jump Power, and the Reset Position.

Resizing a capsule collider and testing it in Play Mode.

image

Collider

Define the boundaries of your character by choosing a collider like a Capsule or a Sphere, and match it perfectly by changing its size, position and rotation.

Gravity

Control how your character jumps and falls. As you make the value closer to 0, the character will float more.

Jump

Define how high your character will jump.

Reset Y Position

Define the value on the Y axis where if the character reaches it, the scene will reset.

This is useful for scenes with platforms which the character can fall from.

Camera Follow

If you need a camera to be following your character, this is where you can define which one will be used for it.

💡
So you stay organized, better collaborate with others and avoid accidental changes, we recommend that you create a new camera for this purpose and use your Personal Camera to move around in the editor.

To create a new camera, you can do so from the “+” icon on the toolbar and selecting Camera, or from the Camera Panel and then pressing “Add new camera” from the dropdown.

Make sure to position the camera in the position you want the experience to be viewed by everyone in the final result.

Difference between a static Camera and a Camera following the character.

image

Camera

Select the camera that is going to be following your character.

Orient To

Normal - When moving the character the camera will follow it by moving forward, backwards, or pan to the sides.

Angle - When moving the character the camera will follow it by moving but also rotate at an angle behind the character.

Up/Down & Left/Right

With the directions Up, Down, Left, and Right, you can decide how the user can control the camera.

You can either allow the user to move it in those directions, disable it, or define limits by using angle values.

Matching Cameras

Remember that the camera used to follow the character should also be the camera defined as the Play Camera in the export settings.

If they’re not, you’ll see this warning, where pressing the button will match the two.

image

If the cameras are all correctly set up, you’ll see this in the export panel, letting you know that the camera is being controlled by a Game Controls event.

Meaning that the camera defined as the Play Camera is currently used to follow a character.

image

👉 Next Steps

Exporting as Public URLs