Class reference
WorldScape3DCollision
Inherits Object
Description
This class manages collision.
Properties
int layer = 1
int layer = 1The physics layers the terrain lives on. Sets [code skip-lint]CollisionObject3D.collision_layer[/code]. Also see mask.
int mask = 1
int mask = 1The physics layers the physics body scans for colliding objects. Sets [code skip-lint]CollisionObject3D.collision_mask[/code]. Also see layer.
int mode = 1
int mode = 1The selected mode determines if collision is generated and how. See CollisionMode for details.
PhysicsMaterial physics_material
PhysicsMaterial physics_materialApplies 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
float priority = 1.0The 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
int radius = 64If mode is Dynamic, this is the distance range within which collision shapes will be generated.
int shape_size = 16
int shape_size = 16If 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
RID get_rid() constReturns the RID of the active StaticBody.
bool is_dynamic_mode() const
bool is_dynamic_mode() constReturns true if mode is [code skip-lint]Dynamic / Editor[/code] or [code skip-lint]Dynamic / Game[/code].
bool is_editor_mode() const
bool is_editor_mode() constReturns true if mode is [code skip-lint]Full / Editor[/code] or [code skip-lint]Dynamic / Editor[/code].
bool is_enabled() const
bool is_enabled() constReturns true if mode is not [code skip-lint]Disabled[/code].
void update(bool rebuild = false)
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
No collision shapes will be generated.
DYNAMIC_GAME = 1
Collision shapes are generated around the camera as it moves; in game only.
DYNAMIC_EDITOR = 2
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
Collision shapes are generated for all regions in game only.
FULL_EDITOR = 4
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.