Up to date
This page is up to date for Godot 4.2
.
If you still find outdated information, please open an issue.
Area3D¶
Inherits: CollisionObject3D < Node3D < Node < Object
A region of 3D space that detects other CollisionObject3Ds entering or exiting it.
Description¶
Area3D is a region of 3D space defined by one or multiple CollisionShape3D or CollisionPolygon3D child nodes. It detects when other CollisionObject3Ds enter or exit it, and it also keeps track of which collision objects haven't exited it yet (i.e. which one are overlapping it).
This node can also locally alter or override physics parameters (gravity, damping) and route audio to custom audio buses.
Warning: Using a ConcavePolygonShape3D inside a CollisionShape3D child of this node (created e.g. by using the Create Trimesh Collision Sibling option in the Mesh menu that appears when selecting a MeshInstance3D node) may give unexpected results, since this collision shape is hollow. If this is not desired, it has to be split into multiple ConvexPolygonShape3Ds or primitive shapes like BoxShape3D, or in some cases it may be replaceable by a CollisionPolygon3D.
Tutorials¶
Properties¶
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
Methods¶
get_overlapping_areas ( ) const |
|
get_overlapping_bodies ( ) const |
|
has_overlapping_areas ( ) const |
|
has_overlapping_bodies ( ) const |
|
overlaps_area ( Node area ) const |
|
overlaps_body ( Node body ) const |
Signals¶
area_entered ( Area3D area )
Emitted when the received area
enters this area. Requires monitoring to be set to true
.
area_exited ( Area3D area )
Emitted when the received area
exits this area. Requires monitoring to be set to true
.
area_shape_entered ( RID area_rid, Area3D area, int area_shape_index, int local_shape_index )
Emitted when a Shape3D of the received area
enters a shape of this area. Requires monitoring to be set to true
.
local_shape_index
and area_shape_index
contain indices of the interacting shapes from this area and the other area, respectively. area_rid
contains the RID of the other area. These values can be used with the PhysicsServer3D.
Example of getting the CollisionShape3D node from the shape index:
var other_shape_owner = area.shape_find_owner(area_shape_index)
var other_shape_node = area.shape_owner_get_owner(other_shape_owner)
var local_shape_owner = shape_find_owner(local_shape_index)
var local_shape_node = shape_owner_get_owner(local_shape_owner)
area_shape_exited ( RID area_rid, Area3D area, int area_shape_index, int local_shape_index )
Emitted when a Shape3D of the received area
exits a shape of this area. Requires monitoring to be set to true
.
See also area_shape_entered.
body_entered ( Node3D body )
Emitted when the received body
enters this area. body
can be a PhysicsBody3D or a GridMap. GridMaps are detected if their MeshLibrary has collision shapes configured. Requires monitoring to be set to true
.
body_exited ( Node3D body )
Emitted when the received body
exits this area. body
can be a PhysicsBody3D or a GridMap. GridMaps are detected if their MeshLibrary has collision shapes configured. Requires monitoring to be set to true
.
body_shape_entered ( RID body_rid, Node3D body, int body_shape_index, int local_shape_index )
Emitted when a Shape3D of the received body
enters a shape of this area. body
can be a PhysicsBody3D or a GridMap. GridMaps are detected if their MeshLibrary has collision shapes configured. Requires monitoring to be set to true
.
local_shape_index
and body_shape_index
contain indices of the interacting shapes from this area and the interacting body, respectively. body_rid
contains the RID of the body. These values can be used with the PhysicsServer3D.
Example of getting the CollisionShape3D node from the shape index:
var body_shape_owner = body.shape_find_owner(body_shape_index)
var body_shape_node = body.shape_owner_get_owner(body_shape_owner)
var local_shape_owner = shape_find_owner(local_shape_index)
var local_shape_node = shape_owner_get_owner(local_shape_owner)
body_shape_exited ( RID body_rid, Node3D body, int body_shape_index, int local_shape_index )
Emitted when a Shape3D of the received body
exits a shape of this area. body
can be a PhysicsBody3D or a GridMap. GridMaps are detected if their MeshLibrary has collision shapes configured. Requires monitoring to be set to true
.
See also body_shape_entered.
Enumerations¶
enum SpaceOverride:
SpaceOverride SPACE_OVERRIDE_DISABLED = 0
This area does not affect gravity/damping.
SpaceOverride SPACE_OVERRIDE_COMBINE = 1
This area adds its gravity/damping values to whatever has been calculated so far (in priority order).
SpaceOverride SPACE_OVERRIDE_COMBINE_REPLACE = 2
This area adds its gravity/damping values to whatever has been calculated so far (in priority order), ignoring any lower priority areas.
SpaceOverride SPACE_OVERRIDE_REPLACE = 3
This area replaces any gravity/damping, even the defaults, ignoring any lower priority areas.
SpaceOverride SPACE_OVERRIDE_REPLACE_COMBINE = 4
This area replaces any gravity/damping calculated so far (in priority order), but keeps calculating the rest of the areas.
Property Descriptions¶
float angular_damp =