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.
- Select the object that should become the character.
- In the inspector, click + new component and choose Events.
- Click + add event.
- Set the trigger to Game controls.
- Adjust the settings described below.
- 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
| Setting | What it controls |
|---|---|
| Movement | Walk, Fly or Top down |
| Towards | what "forward" means: where the Camera looks, or the scene's own Axis |
| Pos. Speed · Run Factor | speed in metres per second, and how much faster the character runs while Shift is held |
| Pos. Delay | how long it takes to reach full speed, and to stop |
| Auto-orient · Rot. Speed | whether the character turns to face where it is going, and how fast |
| Keys | WASD, arrows, or both |
| Jump | jump height in metres; 0 means no jumping |
| Air Control | how much the visitor can steer in mid-jump |
| Rst Y-offset | if the character falls this far below its start, it is put back |
| Click to move | walk to the point the visitor taps |
| Rotate By | turn the view with the mouse, the keys, or both |
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.
| Setting | What it controls |
|---|---|
| Collider | Capsule or Sphere |
| Size | radius and height, in metres |
| Position | moves the capsule relative to the object |
| Mass | how hard the character pushes, and how hard it is to push |
| Helper | shows 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.
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
| Setting | What it controls |
|---|---|
| Camera | which camera follows the character; leave empty for a built-in one |
| Orient To | keep looking At target, or hold a fixed Angle |
| Pos. Delay · Rot. Delay | how far the camera lags behind, in seconds |
| Up / Down · Left / Right | whether the view can turn that way: Yes, No or Limit |
| Limit | how far the view can turn, in degrees |
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.
| Setting | What it controls |
|---|---|
| Touch controls → Enable | shows a stick and a jump button |
| Rotate By | turn the view by Drag across the scene, or with a second Joystick |
| Movement stick · Jump button | where each one sits, on a 3×3 grid |
| Offset · Button Size | distance from the screen edge, and size in pixels |
| Visibility | Hide 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_controlnode haspulseandstateoutputs.
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.