Skip to content

MovementVolume ​

Inherits: SpaceVolume < Area3D

A space that changes how whoever is in it moves: water to swim in, a room with no gravity, a cloud to fly through, a pool of lava that hurts. Put it in a world scene (the Volumes button of the 3D toolbar), give its CollisionShape3D the shape of the space, and choose what it does.

Description ​

  • Movement. Inside it an entity moves in 3D: swimming (the swim animations) or flying (nothing pulls it down), with its own speed, vertical speed and what it does when nobody steers (stay, float to the surface, sink). The player swims up with jump and down with crouch, and moves where the camera looks.
  • Shallow water. A volume with a surface (water) lets entities WADE while the water is shallower than the wade depth: they walk, slower. Deeper, they swim. The top of the shape is the surface; the water you see is a mesh of your own placed there.
  • Breath. A volume can make whoever is under the surface hold its breath (the duration is a setting of the Gameplay Config) and drown when it runs out.
  • Effects. Effects (damage over time for lava, a slow, a buff) that are on whoever is inside, and come off when it leaves.
  • The camera. When the camera itself is inside, the screen is tinted and fogged (an underwater look), and the sound changes with an AudioProfile (muffled under water).

The presets fill the fields for the usual cases: Water, Weightless, Lava and River (the Unique Object panel has a menu of them, and Save as preset for your own).

  • Flow. A volume can carry whoever is in it, like a river or a wind: a direction (the way the volume points: turn it) and a speed. It is added to how they move: a strong current sweeps them away, a weak one can be swum against.
  • The look. A volume draws nothing by itself. Give it a look and it draws the top, the bottom or all six faces of its box shape with a material of yours (a shader, or a texture): the water, the lava,

a cloud. The Water and Lava presets come with a shader of the toolkit.

Properties ​

Stringpreset_name""
PresetpresetPreset.CUSTOM:
MovementClaim.ModemodeMovementClaim.Mode.SWIM
AffectsaffectsAffects.EVERYONE
floatspeed_multiplier0.7
floatvertical_speed3.0
MovementClaim.IdleBuoyancyidle_buoyancyMovementClaim.IdleBuoyancy.FLOAT_UP
boolfollows_camera_pitchtrue
boolhas_surfacetrue
floatwade_depth1.0
floatwade_speed_multiplier0.8
floatswim_depth1.35
boolallows_surface_leaptrue
Submergedholds_breath_whenSubmerged.HEAD_UNDER_SURFACE
floathead_height1.6
Array[int]effects_inside[]
NavigationRulenavigationNavigationRule.WALK_THROUGH
floatflow_strength0.0:
Vector3flow_directionVector3(0.0, 0.0, -1.0):
boolflow_pushes_walkersfalse
VolumeLook.Faceslook_facesVolumeLook.Faces.NONE:
Materiallook_materialnull:
boollook_follows_flowtrue:
Texture2Dlook_texturenull:
Colorlook_tintColor(0.2, 0.5, 0.7, 0.6):
boollook_double_sidedtrue:
intlook_grid24:
boolshore_effectsfalse:
floatshore_wet_height0.4:
boolreflection_probefalse:
boolreflection_probe_updatesfalse:
floatreflection_probe_height4.0:
floatreflection_probe_range20.0:
boolcamera_effect_enabledtrue
Colorcamera_tintColor(0.1, 0.35, 0.45, 0.3)
Colorcamera_fog_colorColor(0.08, 0.28, 0.38)
floatcamera_fog_density0.05
AudioProfileaudio_profilenull
Stringfootstep_surface""
Stringfootstep_swim""

Methods ​

voidapply_preset()
Array[Dictionary]water_shapes()
ReflectionProbeget_reflection_probe()
ArrayMeshget_look_mesh()
Vector3get_flow_velocity()
Vector3get_flow_at( _world_point: Vector3 )
floatget_surface_y_at( _world_point: Vector3 )
floatdepth_of( entity: Entity )
floathorizontal_distance( world_point: Vector3 )

Enumerations ​

enum Preset ​

The usual volumes. Picking one fills the fields below (what you set afterwards is yours)

  • CUSTOM = 0
  • WATER = 1
  • WEIGHTLESS = 2
  • LAVA = 3

enum Affects ​

Who the volume works on

  • EVERYONE = 0
  • PLAYERS = 1
  • NPCS = 2

enum NavigationRule ​

What the navigation of NPCs does with the volume: Walk Through (nothing: shallow water, a flow), Avoid When Deep (land creatures go round the part of the volume that is deeper than the wade depth; water creatures swim in it), Never (nobody walks in it: lava)

  • WALK_THROUGH = 0
  • AVOID_WHEN_DEEP = 1
  • NEVER = 2

enum Submerged ​

When an entity inside holds its breath

  • NEVER = 0
  • HEAD_UNDER_SURFACE = 1
  • ALWAYS_INSIDE = 2

Constants ​

  • float EFFECT_CHECK_INTERVAL = 0.5 - How often (seconds) the entities inside are looked at again for the effects they should have
  • float RECONCILE_INTERVAL = 1.0 - How often (seconds) the bodies inside are counted again, in case the engine missed one entering
  • int LOOK_LAYER = 1 << 19 - The layer of the look when the volume has a reflection probe (layer 20): the probe leaves it out, so the water does not mirror itself. Cameras see all layers

Property descriptions ​

String preset_name = "" ​

The name of the preset this volume was made from (the menu of the Unique Object panel; empty = none). It only says where the numbers came from: they are this volume's own now

Preset preset = Preset.CUSTOM: ​

No description yet.

Movement

MovementClaim.Mode mode = MovementClaim.Mode.SWIM ​

How the entities move inside: swimming, flying, or Ground (they walk: the volume only slows them or applies effects, like lava)

Affects affects = Affects.EVERYONE ​

Who the volume works on

float speed_multiplier = 0.7 ​

The speed inside compared with outside (0.7 = 70 %)

float vertical_speed = 3.0 ​

How fast an entity goes up and down (units per second)

MovementClaim.IdleBuoyancy idle_buoyancy = MovementClaim.IdleBuoyancy.FLOAT_UP ​

What an entity does when nobody steers it: stay where it is, rise to the surface, or sink

bool follows_camera_pitch = true ​

Moving forward goes where the camera looks, up and down included (a camera that looks around freely; the top-down cameras never do)

Surface and shallow water

bool has_surface = true ​

The top of the shape is a surface (water): an entity cannot swim up through it and floats just below it. Off for a volume with no top (a weightless room, the sky)

float wade_depth = 1.0 ​

Where the water is shallower than this an entity wades (walks, slower); deeper it swims. 0 = it swims as soon as it is in. Needs a surface

float wade_speed_multiplier = 0.8 ​

The speed while wading compared with outside the water

float swim_depth = 1.35 ​

How deep a swimmer sits in the water: the distance from the surface down to its feet while it floats, in metres. About the height of a person's shoulders, so that the body is in the water and the head is out. Swimming up stops a little higher than this. 0 = worked out from the wade depth (80 %)

bool allows_surface_leap = true ​

An entity swimming up to the surface can leap out of the water with jump

Breath

Submerged holds_breath_when = Submerged.HEAD_UNDER_SURFACE ​

When an entity inside holds its breath: never, when its head is under the surface, or always when inside (a room with no air). The duration is in the Gameplay Config > Breath

float head_height = 1.6 ​

How high above its feet the head of an entity is (to know when it is under the surface)

Effects while inside

Array[int] effects_inside = [] ​

Effects that are on every entity inside while it is inside (a damage over time for lava, a slow). They are put back when they end, and taken off when the entity leaves

Navigation

NavigationRule navigation = NavigationRule.WALK_THROUGH ​

What the navigation of NPCs does with this volume (see the bake of the terrain): Walk Through, Avoid When Deep (water: land creatures go round where it is deeper than the wade depth, water creatures swim in it) or Never (lava: no NPC walks in it). The Water preset is Avoid When Deep and the Lava preset Never. The terrain navigation has to be baked again to show it

Flow

float flow_strength = 0.0: ​

How fast the water or the air carries whoever is in it, in metres per second (0 = it is still). A river, a current, a wind

Vector3 flow_direction = Vector3(0.0, 0.0, -1.0): ​

The way it carries them, in the space of the volume: turn the volume to point it (the default is the front of the volume, -Z)

bool flow_pushes_walkers = false ​

Carries entities that walk through it (shallow water) too, and not only the ones that swim or fly

Look

VolumeLook.Faces look_faces = VolumeLook.Faces.NONE: ​

What the volume draws: nothing, the top face (water), the bottom, or all six faces (a box of fog). It is made from a BOX shape; other shapes draw nothing

Material look_material = null: ​

The material of the look: any material, a ShaderMaterial included. Empty = a plain material with the texture and the tint below

bool look_follows_flow = true: ​

When the shader of the material has a flow direction and a flow speed (the river shader), they are the flow of this volume, set for you. Turn it off to set them yourself in the parameters below

Texture2D look_texture = null: ​

A texture for the plain material (used when there is no material above)

Color look_tint = Color(0.2, 0.5, 0.7, 0.6): ​

The tint of the plain material (the alpha makes it see-through)

bool look_double_sided = true: ​

Every face is made twice, looking both ways, so the surface is seen from under it too

int look_grid = 24: ​

How many cells the top and the bottom are cut in along the long side: a shader that moves the surface (waves) needs the vertices. 0 = worked out from the size of the volume (about half a metre a cell, up to 128), which water wants

bool shore_effects = false: ​

The ground near this water is wet (darker and shinier, the way each texture is when it rains) and the bed under it shows the light of caustics: the shimmer of water on a bottom. The terrain does it, from the height of the water (a map the volume gives it); the ground and the water must be in the world of a terrain. For water: the Water and River presets have it on

float shore_wet_height = 0.4: ​

How high above the water the ground is still wet, in metres: a flat bank is wet over a wide strip, a steep one over a narrow strip. 0 = no wet shore, only the caustics under the water

Reflections

bool reflection_probe = false: ​

Gives the water a reflection probe: a picture of what is around it (trees, rocks, buildings, not only the sky), taken from above the water, that the water mirrors. For a box shape. The probe is only as exact as one picture from one point: good for a pond or a lake, rough for a long river (use several volumes). It also changes the reflections of what stands inside its box

bool reflection_probe_updates = false: ​

Take the picture again every frame, so that what moves shows in the water (it costs more). Off: once, when the volume is made

float reflection_probe_height = 4.0: ​

How high above the water the picture is taken, in metres

float reflection_probe_range = 20.0: ​

How far around the volume the probe sees and reaches, in metres

Camera

bool camera_effect_enabled = true ​

When the camera is inside the volume the screen gets the look below (the camera, not the character: a swimmer with its head above the surface sees clearly)

Color camera_tint = Color(0.1, 0.35, 0.45, 0.3) ​

The color laid over the screen (the alpha is how strong)

Color camera_fog_color = Color(0.08, 0.28, 0.38) ​

The color of the fog inside

float camera_fog_density = 0.05 ​

How thick the fog is (0 = none)

Sound

AudioProfile audio_profile = null ​

How the sound changes while the camera is inside (muffled under water; echo in a cave). Empty = the sound does not change. The camera, not the character, decides

String footstep_surface = "" ​

What the footsteps of whoever is in the volume sound like while they WALK or WADE: the kind of ground (the words of the folders of your footstep sounds: "water", "mud", "snow"). It wins over the terrain and the surface type of the floor. Empty = the ground under them decides

String footstep_swim = "" ​

What the sounds of whoever SWIMS in the volume are: the kind of ground ("water_deep"). A swimmer makes the "swim" sounds of it, and the "jump" sounds when it jumps into the water (and does not land: it is in the volume) or leaps out of it. Empty = the footstep surface above is used, and "water" when that is empty too

Method descriptions ​

void apply_preset() ​

Fills the fields from the preset (picking a preset in the inspector does this; code that makes a volume calls it).

Array[Dictionary] water_shapes() ​

The shapes of water this volume gives the picture of the water (see WaterMapData): its box. Empty for a volume that is not water or has no box

ReflectionProbe get_reflection_probe() ​

The probe of the volume (null when it has none)

ArrayMesh get_look_mesh() ​

The mesh of the look (null when there is none).

Vector3 get_flow_velocity() ​

The push of the flow in the world: the direction of the volume turned the way the volume is turned, at the strength of the flow. Zero when it does not flow.

Vector3 get_flow_at( _world_point: Vector3 ) ​

The push of the flow at a point of the world. Everywhere the same for a box; a river runs along its course, so it differs from place to place (RiverVolume)

float get_surface_y_at( _world_point: Vector3 ) ​

The height of the water surface at a point of the world (the top of the box; a river is higher or lower from place to place)

float depth_of( entity: Entity ) ​

How deep an entity stands below the surface (its feet)

float horizontal_distance( world_point: Vector3 ) ​

How far a point of the world is from the water of this volume, seen from above (0 over it): the box of its first box shape, else far away. Where the end of a river can join it