Skip to reading
GDScript Programming & Godot

Gameplay: Room changes, 2D controls and environmental state

Edition 0.86.4.1 HF1

0.86.4.1 Hotfix 1 edition. Earlier lessons and screenshots retain their original version context; revised references and supplements describe the newer behavior.

Download PDFView PDF page

Keep room transitions at the end of a local sequence where possible. After changing rooms, an old-room object ID may no longer resolve. Layer and depth commands apply to the 2D/hybrid scene systems, not to arbitrary 3D model transforms.

ChangeScene()#

Change Scene

Move the active player into another scene using a spawn and optional destination position/camera/transition settings.

Source table from Gameplay: Room changes, 2D controls and environmental state, page 148
Option key / fieldMeaning and inputDefault
Destination Scene sceneIdChoose a scene ID.-
Spawn (optional) spawnIdChoose an arrival spawn in the destination scene. May be blank.Blank
XYZ when no spawn positionDestination/placement coordinates as [X, Y, Z].[0.0, 0.0, 0.0]

Timing. Awaits the room-change routine.

Code example
await ChangeScene({"sceneId": "lab", "spawnId": "", "position": [0.0, 0.0, 0.0]})

In use. Choose The Archive and the from_signal spawn. Native room/object event inspectors expose Destination Scene and transition controls. Some shared action forms omit the scene selector; call a visual or text script from those surfaces instead. A spawn is usually clearer than loose coordinates.

sceneId is accepted by the runtime even though some shared forms omit that field. Native GDScript can supply it directly as shown. Use this room-change route instead of replacing the top-level Godot SceneTree scene.

Page 148 of 378Permalink
Go to page