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" (PhysicsBody2D body)

Emitted when a PhysicsBody2D object enters.

    "body_exited" (PhysicsBody2D body)

Emitted when a PhysicsBody2D object exits.

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

Emitted when a PhysicsBody2D object enters, reporting which shapes overlapped.

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

Emitted when a PhysicsBody2D object exits, reporting which shapes were overlapping.

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. Default value: false.

    public int 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 int 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). Also see SpaceOverride. Default value: false.

    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. Default value: true.

    public bool Monitoring { get; set; }

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

    public float Priority { get; set; }

The area’s priority. Higher priority areas are processed first. Default value: 0.

    public SpaceOverrideEnum SpaceOverride { get; set; }

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

Methods

    public float GetAngularDamp()

Getter for AngularDamp

    public string GetAudioBusName()

Getter for AudioBusName

    public int GetCollisionLayer()

Getter for CollisionLayer

    public bool GetCollisionLayerBit(int bit)

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

    public int GetCollisionMask()

Getter for CollisionMask

    public bool GetCollisionMaskBit(int bit)

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

    public float GetGravity()

Getter for Gravity

    public float GetGravityDistanceScale()

Getter for GravityDistanceScale

    public Vector2 GetGravityVector()

Getter for GravityVec

    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.

    public float GetPriority()

Getter for Priority

    public SpaceOverrideEnum GetSpaceOverrideMode()

Getter for SpaceOverride

    public bool IsGravityAPoint()

Getter for GravityPoint

    public bool IsMonitorable()

Getter for Monitorable

    public bool IsMonitoring()

Getter for Monitoring

    public bool IsOverridingAudioBus()

Getter for AudioBusOverride

    public bool OverlapsArea(Node area)

If true, the given area overlaps the Area2D. Note that 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 body overlaps the Area2D. Note that 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 void SetAngularDamp(float angularDamp)

Setter for AngularDamp

    public void SetAudioBusName(string name)

Setter for AudioBusName

    public void SetAudioBusOverride(bool enable)

Setter for AudioBusOverride

    public void SetCollisionLayer(int collisionLayer)

Setter for 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.

    public void SetCollisionMask(int collisionMask)

Setter for CollisionMask

    public void SetCollisionMaskBit(int bit, bool value)

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

    public void SetGravity(float gravity)

Setter for Gravity

    public void SetGravityDistanceScale(float distanceScale)

Setter for GravityDistanceScale

    public void SetGravityIsPoint(bool enable)

Setter for GravityPoint

    public void SetGravityVector(Vector2 vector)

Setter for GravityVec

    public void SetLinearDamp(float linearDamp)

Setter for LinearDamp

    public void SetMonitorable(bool enable)

Setter for Monitorable

    public void SetMonitoring(bool enable)

Setter for Monitoring

    public void SetPriority(float priority)

Setter for Priority

    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: