2D area for detection and 2D physics influence.
    public class Area2D : CollisionObject2D

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

Inheritance Chain

Constructors

    public Area2D()

Signals

    "area_entered" (Area2D area)

Emitted when another area enters.

    "area_exited" (Area2D area)

Emitted when another area exits.

    "area_shape_entered" (int area_id, Area2D area, int area_shape, int self_shape)

Emitted when another area enters, reporting which shapes overlapped.

    "area_shape_exited" (int area_id, Area2D area, int area_shape, int self_shape)

Emitted when another area exits, reporting which shapes were overlapping.

    "body_entered" (Node body)

Emitted when a physics body enters.

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).

    "body_exited" (Node body)

Emitted when a physics body exits.

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).

    "body_shape_entered" (int body_id, Node body, int body_shape, int area_shape)

Emitted when a physics body enters, reporting which shapes overlapped.

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).

    "body_shape_exited" (int body_id, Node body, int body_shape, int area_shape)

Emitted when a physics body exits, reporting which shapes were overlapping.

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).

Properties

    public float AngularDamp { get; set; }

The 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).

    public string AudioBusName { get; set; }

The name of the area’s audio bus.

    public bool AudioBusOverride { get; set; }

If true, the area’s audio bus overrides the default audio bus.

    public uint CollisionLayer { get; set; }

The 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.

    public uint CollisionMask { get; set; }

The physics layers this area scans to determine collision detection.

    public float Gravity { get; set; }

The 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.

    public float GravityDistanceScale { get; set; }

The falloff factor for point gravity. The greater the value, the faster gravity decreases with distance.

    public bool GravityPoint { get; set; }

If true, gravity is calculated from a point (set via GravityVec). See also SpaceOverride.

    public Vector2 GravityVec { get; set; }

The area’s gravity vector (not normalized). If gravity is a point (see GravityPoint), this will be the point of attraction.

    public float LinearDamp { get; set; }

The 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).

    public bool Monitorable { get; set; }

If true, other monitoring areas can detect this area.

    public bool Monitoring { get; set; }

If true, the area detects bodies or areas entering and exiting it.

    public float Priority { get; set; }

The area’s priority. Higher priority areas are processed first.

    public SpaceOverrideEnum SpaceOverride { get; set; }

Override mode for gravity and damping calculations within this area. See SpaceOverride for possible values.

Methods

    [Obsolete("GetAngularDamp is deprecated. Use the AngularDamp property instead.")]
    public float GetAngularDamp()

Getter for AngularDamp

    [Obsolete("GetAudioBusName is deprecated. Use the AudioBusName property instead.")]
    public string GetAudioBusName()

Getter for AudioBusName

    [Obsolete("GetCollisionLayer is deprecated. Use the CollisionLayer property instead.")]
    public uint GetCollisionLayer()

    public bool GetCollisionLayerBit(int bit)

Returns an individual bit on the layer mask. Describes whether other areas will collide with this one on the given layer.

    [Obsolete("GetCollisionMask is deprecated. Use the CollisionMask property instead.")]
    public uint GetCollisionMask()

    public bool GetCollisionMaskBit(int bit)

Returns an individual bit on the collision mask. Describes whether this area will collide with others on the given layer.

    [Obsolete("GetGravity is deprecated. Use the Gravity property instead.")]
    public float GetGravity()

Getter for Gravity

    [Obsolete("GetGravityDistanceScale is deprecated. Use the GravityDistanceScale property instead.")]
    public float GetGravityDistanceScale()

Getter for GravityDistanceScale

    [Obsolete("GetGravityVector is deprecated. Use the GravityVec property instead.")]
    public Vector2 GetGravityVector()

Getter for GravityVec

    [Obsolete("GetLinearDamp is deprecated. Use the LinearDamp property instead.")]
    public float GetLinearDamp()

Getter for LinearDamp

    public Godot.Collections.Array 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.

    public Godot.Collections.Array 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.

    [Obsolete("GetPriority is deprecated. Use the Priority property instead.")]
    public float GetPriority()

Getter for Priority

    [Obsolete("GetSpaceOverrideMode is deprecated. Use the SpaceOverride property instead.")]
    public SpaceOverrideEnum GetSpaceOverrideMode()

Getter for SpaceOverride

    [Obsolete("IsGravityAPoint is deprecated. Use the GravityPoint property instead.")]
    public bool IsGravityAPoint()

Getter for GravityPoint

    [Obsolete("IsMonitorable is deprecated. Use the Monitorable property instead.")]
    public bool IsMonitorable()

Getter for Monitorable

    [Obsolete("IsMonitoring is deprecated. Use the Monitoring property instead.")]
    public bool IsMonitoring()

Getter for Monitoring

    [Obsolete("IsOverridingAudioBus is deprecated. Use the AudioBusOverride property instead.")]
    public bool IsOverridingAudioBus()

Getter for AudioBusOverride

    public bool OverlapsArea(Node area)

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.

    public bool OverlapsBody(Node body)

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).

    [Obsolete("SetAngularDamp is deprecated. Use the AngularDamp property instead.")]
    public void SetAngularDamp(float angularDamp)

Setter for AngularDamp

    [Obsolete("SetAudioBusName is deprecated. Use the AudioBusName property instead.")]
    public void SetAudioBusName(string name)

Setter for AudioBusName

    [Obsolete("SetAudioBusOverride is deprecated. Use the AudioBusOverride property instead.")]
    public void SetAudioBusOverride(bool enable)

Setter for AudioBusOverride

    [Obsolete("SetCollisionLayer is deprecated. Use the CollisionLayer property instead.")]
    public void SetCollisionLayer(uint collisionLayer)

    public void SetCollisionLayerBit(int bit, bool value)

Set/clear individual bits on the layer mask. This makes getting an area in/out of only one layer easier.

    [Obsolete("SetCollisionMask is deprecated. Use the CollisionMask property instead.")]
    public void SetCollisionMask(uint collisionMask)

    public void SetCollisionMaskBit(int bit, bool value)

Set/clear individual bits on the collision mask. This makes selecting the areas scanned easier.

    [Obsolete("SetGravity is deprecated. Use the Gravity property instead.")]
    public void SetGravity(float gravity)

Setter for Gravity

    [Obsolete("SetGravityDistanceScale is deprecated. Use the GravityDistanceScale property instead.")]
    public void SetGravityDistanceScale(float distanceScale)

Setter for GravityDistanceScale

    [Obsolete("SetGravityIsPoint is deprecated. Use the GravityPoint property instead.")]
    public void SetGravityIsPoint(bool enable)

Setter for GravityPoint

    [Obsolete("SetGravityVector is deprecated. Use the GravityVec property instead.")]
    public void SetGravityVector(Vector2 vector)

Setter for GravityVec

    [Obsolete("SetLinearDamp is deprecated. Use the LinearDamp property instead.")]
    public void SetLinearDamp(float linearDamp)

Setter for LinearDamp

    [Obsolete("SetMonitorable is deprecated. Use the Monitorable property instead.")]
    public void SetMonitorable(bool enable)

Setter for Monitorable

    [Obsolete("SetMonitoring is deprecated. Use the Monitoring property instead.")]
    public void SetMonitoring(bool enable)

Setter for Monitoring

    [Obsolete("SetPriority is deprecated. Use the Priority property instead.")]
    public void SetPriority(float priority)

Setter for Priority

    [Obsolete("SetSpaceOverrideMode is deprecated. Use the SpaceOverride property instead.")]
    public void SetSpaceOverrideMode(SpaceOverrideEnum spaceOverrideMode)

Setter for SpaceOverride

Inner Types

SpaceOverrideEnum

Name Value Description
Disabled 0 This area does not affect gravity/damping.
Combine 1 This area adds its gravity/damping values to whatever has been calculated so far (in [member priority] order).
CombineReplace 2 This area adds its gravity/damping values to whatever has been calculated so far (in [member priority] order), ignoring any lower priority areas.
Replace 3 This area replaces any gravity/damping, even the defaults, ignoring any lower priority areas.
ReplaceCombine 4 This area replaces any gravity/damping calculated so far (in [member priority] order), but keeps calculating the rest of the areas.
Tags: