Skip to main content

Game controls

Game controls turn an object into a character your visitor can move: walking, flying, or moving around a top-down map. This page shows how to set it up and what each setting does.

What you need​

  • A character: the object with the Game controls trigger.
  • Something solid to stand on: a floor with a rigid body and a collider.
  • A camera, or none. If you do not pick one, a built-in camera is used.

Add game controls​

Game controls are a trigger, not a step. All the controller settings live in the trigger.

  1. Select the object that should become the character.
  2. In the inspector, click + new component and choose Events.
  3. Click + add event.
  4. Set the trigger to Game controls.
  5. Adjust the settings described below.
  6. Optional: add steps to the branches On idle, On move, On run and On jump to react to what the character is doing, for example to play an animation.

The controller exists as long as its object is on. Turn the object off and the controller is gone. Turn it on again and the controller comes back.

Movement​

SettingWhat it controls
MovementWalk, Fly or Top down
Towardswhat "forward" means: where the Camera looks, or the scene's own Axis
Pos. Speed · Run Factorspeed in metres per second, and how much faster the character runs while Shift is held
Pos. Delayhow long it takes to reach full speed, and to stop
Auto-orient · Rot. Speedwhether the character turns to face where it is going, and how fast
KeysWASD, arrows, or both
Jumpjump height in metres; 0 means no jumping
Air Controlhow much the visitor can steer in mid-jump
Rst Y-offsetif the character falls this far below its start, it is put back
Click to movewalk to the point the visitor taps
Rotate Byturn the view with the mouse, the keys, or both
Pos. Delay is a time

Say you set half a second. The character then reaches full speed in half a second. Slopes, bumps and mass all slow it down, which makes movement feel physical.

0 means "as fast as possible". That is almost instant, but not quite, because the character still has mass.

The body​

The controller gives your object a capsule. So the character bumps into the world instead of passing through it.

SettingWhat it controls
ColliderCapsule or Sphere
Sizeradius and height, in metres
Positionmoves the capsule relative to the object
Masshow hard the character pushes, and how hard it is to push
Helpershows the capsule in the editor

If the object already has its own rigid body, the controller keeps it and only steers it, using its mass. Otherwise the controller makes one for you.

Only objects with a body are solid

Floors and walls stop the character only if they have a rigid body and a collider. Other geometry is only scenery, and the character walks through it. → Physics

Gravity comes from the space, and jump height is measured against it. A scene with game controls turns physics on, even if the space had it off. Without physics, nothing would move.

The follow camera​

SettingWhat it controls
Camerawhich camera follows the character; leave empty for a built-in one
Orient Tokeep looking At target, or hold a fixed Angle
Pos. Delay · Rot. Delayhow far the camera lags behind, in seconds
Up / Down · Left / Rightwhether the view can turn that way: Yes, No or Limit
Limithow far the view can turn, in degrees
Frame the shot in the viewport

On the first frame, the camera remembers its distance and angle to the character, and keeps them. You do not type any distance or height. Put the camera where it looks right in the viewport, and it stays there.

How the camera behaves:

  • It turns toward the character before it moves. The character can drift a little to the side while the camera only rotates. The camera slides only when the character reaches the edge of that area. This feels more natural than a camera fixed tightly to the character.
  • Lag changes the framing, not the distance. The camera does not fall back as the character speeds up. That would look like an unwanted zoom and can make people feel queasy.
  • The camera swings round behind the character while it moves and the visitor is not turning the view. Locking Left / Right, or choosing Top down, turns this off.
  • Nothing blocks the view. If something comes between the camera and the character, the camera moves closer, then eases back out. It never comes closer than half a metre.
  • The mouse wheel zooms, from about a third to two and a half times the distance you set.

While the controller drives a camera, that camera's own controls (orbit, fly) are ignored. Otherwise they would fight each other on every frame.

Touch controls and gamepads​

On-screen controls appear only on touch screens, so you can leave them on.

SettingWhat it controls
Touch controls → Enableshows a stick and a jump button
Rotate Byturn the view by Drag across the scene, or with a second Joystick
Movement stick · Jump buttonwhere each one sits, on a 3×3 grid
Offset · Button Sizedistance from the screen edge, and size in pixels
VisibilityHide the controls; swiping to turn still works

A gamepad works with no setup:

  • the left stick moves;
  • the right stick looks around;
  • A jumps;
  • the bumpers and triggers run.

React to what the character does​

The branches On idle, On move, On run and On jump run when the character changes what it is doing. Scripts and patches get the same change at the same moment:

  • a script can listen for it;
  • in a patch, the on_game_control node has pulse and state outputs.

So you can play footstep sounds from a script while the branches handle animation, and both stay in step.

Follow without a controller​

For something simpler, like an enemy trailing the player, a pet or a camera target, use the Follow object, Look at object and Stop following steps.

These steps move the object directly. So they do not work on an object that physics already moves. For that, push it with impulses from a script.


Next: UI cards — buttons, menus and score displays.