Struct Area2D

2D area for detection and 2D physics influence.

struct Area2D ;

2D area that detects CollisionObject2D nodes overlapping, entering, or exiting. Can also alter or override local physics parameters (gravity, damping).

Properties

NameTypeDescription
angularDamp[get, set] doubleThe rate at which objects stop spinning in this area. Represents the angular velocity lost per second. Values range from 0 (no damping) to 1 (full damping).
audioBusName[get, set] StringThe name of the area's audio bus.
audioBusOverride[get, set] boolIf true, the area's audio bus overrides the default audio bus.
collisionLayer[get, set] longThe area's physics layer(s). Collidable objects can exist in any of 32 different layers. A contact is detected if object A is in any of the layers that object B scans, or object B is in any layers that object A scans. See also collisionMask.
collisionMask[get, set] longThe physics layers this area scans to determine collision detection.
gravity[get, set] doubleThe area's gravity intensity (ranges from -1024 to 1024). This value multiplies the gravity vector. This is useful to alter the force of gravity without altering its direction.
gravityDistanceScale[get, set] doubleThe falloff factor for point gravity. The greater the value, the faster gravity decreases with distance.
gravityPoint[get, set] boolIf true, gravity is calculated from a point (set via gravityVec). See also spaceOverride.
gravityVec[get, set] Vector2The area's gravity vector (not normalized). If gravity is a point (see gravityPoint), this will be the point of attraction.
linearDamp[get, set] doubleThe rate at which objects stop moving in this area. Represents the linear velocity lost per second. Values range from 0 (no damping) to 1 (full damping).
monitorable[get, set] boolIf true, other monitoring areas can detect this area.
monitoring[get, set] boolIf true, the area detects bodies or areas entering and exiting it.
priority[get, set] doubleThe area's priority. Higher priority areas are processed first.
spaceOverride[get, set] Area2D.SpaceOverrideOverride mode for gravity and damping calculations within this area. See spaceoverride for possible values.

Methods

NameDescription
_areaEnterTree
_areaExitTree
_areaInout
_bodyEnterTree
_bodyExitTree
_bodyInout
getAngularDamp
getAudioBusName
getCollisionLayer
getCollisionLayerBit Returns an individual bit on the layer mask. Describes whether other areas will collide with this one on the given layer.
getCollisionMask
getCollisionMaskBit Returns an individual bit on the collision mask. Describes whether this area will collide with others on the given layer.
getGravity
getGravityDistanceScale
getGravityVector
getLinearDamp
getOverlappingAreas Returns a list of intersecting Area2Ds. For performance reasons (collisions are all processed at the same time) this list is modified once during the physics step, not immediately after objects are moved. Consider using signals instead.
getOverlappingBodies Returns a list of intersecting PhysicsBody2Ds. For performance reasons (collisions are all processed at the same time) this list is modified once during the physics step, not immediately after objects are moved. Consider using signals instead.
getPriority
getSpaceOverrideMode
isGravityAPoint
isMonitorable
isMonitoring
isOverridingAudioBus
overlapsArea If true, the given area overlaps the Area2D. Note: The result of this test is not immediate after moving objects. For performance, list of overlaps is updated once per frame and before the physics step. Consider using signals instead.
overlapsBody If true, the given physics body overlaps the Area2D. Note: The result of this test is not immediate after moving objects. For performance, list of overlaps is updated once per frame and before the physics step. Consider using signals instead. The body argument can either be a PhysicsBody2D or a TileMap instance (while TileMaps are not physics body themselves, they register their tiles with collision shapes as a virtual physics body).
setAngularDamp
setAudioBusName
setAudioBusOverride
setCollisionLayer
setCollisionLayerBit Set/clear individual bits on the layer mask. This makes getting an area in/out of only one layer easier.
setCollisionMask
setCollisionMaskBit Set/clear individual bits on the collision mask. This makes selecting the areas scanned easier.
setGravity
setGravityDistanceScale
setGravityIsPoint
setGravityVector
setLinearDamp
setMonitorable
setMonitoring
setPriority
setSpaceOverrideMode

Enums

NameDescription
Constants
SpaceOverride