Terrain3DCollision
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 |
update(rebuild: |
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
int
layer = 1
🔗
void set_layer(value:
int
)int
get_layer()
The physics layers the terrain lives on. Sets CollisionObject3D.collision_layer
. Also see mask.
int
mask = 1
🔗
void set_mask(value:
int
)int
get_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 Godot 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 Terrain3DData.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
🔗
void set_priority(value:
float
)float
get_priority()
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
.
int
radius = 64
🔗
void set_radius(value:
int
)int
get_radius()
If mode is Dynamic, this is the distance range within which collision shapes will be generated.
int
shape_size = 16
🔗
void set_shape_size(value:
int
)int
get_shape_size()
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.
RID
get_rid() const 🔗
Returns the RID of the active StaticBody.
bool
is_dynamic_mode() const 🔗
Returns true if mode is Dynamic / Editor
or Dynamic / Game
.
bool
is_editor_mode() const 🔗
Returns true if mode is Full / Editor
or Dynamic / Editor
.
bool
is_enabled() const 🔗
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
rebuild
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
rebuild
to true to recalculate all shapes within radius. This is very fast, and can be updated at 60fps for little cost.