Attention: Here be dragons (unstable version)
This is the latest
(unstable) version of this documentation, which may document features
not available in or compatible with released stable versions of Redot.
Checking the stable version of the documentation...
WorldScape3DCollision
Inherits: Object
Description
This class manages collision.
Properties
|
||
|
||
|
||
|
||
|
||
|
Methods
void |
build() |
void |
destroy() |
get_rid() const |
|
is_dynamic_mode() const |
|
is_editor_mode() const |
|
is_enabled() const |
|
void |
Enumerations
enum CollisionMode: 🔗
CollisionMode DISABLED = 0
No collision shapes will be generated.
CollisionMode DYNAMIC_GAME = 1
Collision shapes are generated around the camera as it moves; in game only.
CollisionMode DYNAMIC_EDITOR = 2
Collision shapes are generated around the camera as it moves; in the editor and in game. Enable View Gizmos in the viewport menu to see them.
CollisionMode FULL_GAME = 3
Collision shapes are generated for all regions in game only.
CollisionMode 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 View Gizmos in the viewport menu to see the collision mesh.
Property Descriptions
The physics layers the terrain lives on. Sets CollisionObject3D.collision_layer. Also see mask.
The physics layers the physics body scans for colliding objects. Sets CollisionObject3D.collision_mask. Also see layer.
CollisionMode mode = 1 🔗
void set_mode(value: CollisionMode)
CollisionMode get_mode()
The selected mode determines if collision is generated and how. See CollisionMode for details.
PhysicsMaterial physics_material 🔗
void set_physics_material(value: PhysicsMaterial)
PhysicsMaterial get_physics_material()
Applies a PhysicsMaterial 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.
The priority with which the physics server uses to solve collisions. The higher the priority, the lower the penetration of a colliding object. Sets CollisionObject3D.collision_priority.
If mode is Dynamic, this is the distance range within which collision shapes will be generated.
If mode is Dynamic, this is the size of each collision shape.
Method Descriptions
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.
Returns the RID of the active StaticBody.
bool is_dynamic_mode() const 🔗
Returns true if mode is Dynamic / Editor or Dynamic / Game.
Returns true if mode is Full / Editor or Dynamic / Editor.
Returns true if mode is not Disabled.
void update(rebuild: bool = false) 🔗
If mode is Full, recalculates the existing collision shapes. If regions have been added or removed, set
rebuildto true or call build() instead. Can be slow.If mode is Dynamic, repositions collision shapes around the camera and recalculates ones that moved. Set
rebuildto true to recalculate all shapes within radius. This is very fast, and can be updated at 60fps for little cost.