Class reference

WorldScape3DCollision

Inherits Object

Description

This class manages collision.

Properties

int layer = 1

The physics layers the terrain lives on. Sets [code skip-lint]CollisionObject3D.collision_layer[/code]. Also see mask.

int mask = 1

The physics layers the physics body scans for colliding objects. Sets [code skip-lint]CollisionObject3D.collision_mask[/code]. Also see layer.

int mode = 1

The selected mode determines if collision is generated and how. See CollisionMode for details.

PhysicsMaterial physics_material

Applies a [code skip-lint]PhysicsMaterial[/code] override to the StaticBody. There's no ability built into Redot to change physics material parameters based on texture or any other factor. However, it might be possible to extend `PhysicsMaterial` in order to inject code into the queries. It would need references to an object position and a terrain, and then it could run WorldScape3DData.get_texture_id() based on the position and return different physics settings per texture. That would change the settings for the entire terrain for that moment.

float priority = 1.0

The priority with which the physics server uses to solve collisions. The higher the priority, the lower the penetration of a colliding object. Sets [code skip-lint]CollisionObject3D.collision_priority[/code].

int radius = 64

If mode is Dynamic, this is the distance range within which collision shapes will be generated.

int shape_size = 16

If mode is Dynamic, this is the size of each collision shape.

Methods

void build()

Creates collision shapes and calls update() to shape them. Calls destroy() first, so it is safe to call this to fully rebuild collision any time.

void destroy()

Removes all collision shapes and frees any memory used.

RID get_rid() const

Returns the RID of the active StaticBody.

bool is_dynamic_mode() const

Returns true if mode is [code skip-lint]Dynamic / Editor[/code] or [code skip-lint]Dynamic / Game[/code].

bool is_editor_mode() const

Returns true if mode is [code skip-lint]Full / Editor[/code] or [code skip-lint]Dynamic / Editor[/code].

bool is_enabled() const

Returns true if mode is not [code skip-lint]Disabled[/code].

void update(bool rebuild = false)

- If mode is Full, recalculates the existing collision shapes. If regions have been added or removed, set [code skip-lint]rebuild[/code] to true or call build() instead. Can be slow. - If mode is Dynamic, repositions collision shapes around the camera and recalculates ones that moved. Set [code skip-lint]rebuild[/code] to true to recalculate all shapes within radius. This is very fast, and can be updated at 60fps for little cost.

Constants

DISABLED = 0

Enum: CollisionMode

No collision shapes will be generated.

DYNAMIC_GAME = 1

Enum: CollisionMode

Collision shapes are generated around the camera as it moves; in game only.

DYNAMIC_EDITOR = 2

Enum: CollisionMode

Collision shapes are generated around the camera as it moves; in the editor and in game. Enable [code skip-lint]View Gizmos[/code] in the viewport menu to see them.

FULL_GAME = 3

Enum: CollisionMode

Collision shapes are generated for all regions in game only.

FULL_EDITOR = 4

Enum: CollisionMode

Collision shapes are generated for all regions in the editor and in game. This mode is necessary for some 3rd party plugins to detect the terrain using collision. Enable [code skip-lint]View Gizmos[/code] in the viewport menu to see the collision mesh.

Source revision 5592dc3a7a61
Connection interrupted. Reload×

Rejoining the server...

Rejoin failed... trying again in seconds.

Failed to rejoin.
Please retry or reload the page.

The session has been paused by the server.

Failed to resume the session.
Please retry or reload the page.