reckfellENGINE

Area2D

An overlap-detection and local physics-field area.

On this page
class Area2DReckfellSharpInherits CollisionObject2D

Area2D detects bodies/areas and can override gravity, damping and an audio bus. It does not become a solid wall. Its Mask tests target Layer; detection requires Monitoring and an active shape.

Monitorable permits other areas to detect this area and does not replace Monitoring. Overlap lists update on physics ticks. In entry/exit signals, set a handled flag before deferring Monitoring/shape changes. Zero gravity does not clear existing velocity.

Guide and example.

Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.

Constructors1

Area2DConstructor
# Area2D
C#
public Area2D();

Properties15

AngularDampProperty
# AngularDamp
C#
public float AngularDamp { get; set; }

The rate at which objects stop spinning in this area. Represents the angular velocity lost per second. See ProjectSettings.physics/2d/default_angular_damp for more details about damping.

AngularDampSpaceOverrideProperty
# AngularDampSpaceOverride
C#
public Area2D.SpaceOverride AngularDampSpaceOverride { get; set; }

Override mode for angular damping calculations within this area.

AudioBusNameProperty
# AudioBusName
C#
public StringName AudioBusName { get; set; }

The name of the area's audio bus.

AudioBusOverrideProperty
# AudioBusOverride
C#
public bool AudioBusOverride { get; set; }

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

GravityProperty
# Gravity
C#
public float Gravity { get; set; }

The area's gravity intensity (in pixels per second squared). This value multiplies the gravity direction. This is useful to alter the force of gravity without altering its direction.

GravityDirectionProperty
# GravityDirection
C#
public Vector2 GravityDirection { get; set; }

The area's gravity vector (not normalized).

GravityPointProperty
# GravityPoint
C#
public bool GravityPoint { get; set; }

If true, gravity is calculated from a point (set via Area2D.GravityPointCenter). See also Area2D.GravitySpaceOverride.

GravityPointCenterProperty
# GravityPointCenter
C#
public Vector2 GravityPointCenter { get; set; }

If gravity is a point (see Area2D.GravityPoint), this will be the point of attraction.

GravityPointUnitDistanceProperty
# GravityPointUnitDistance
C#
public float GravityPointUnitDistance { get; set; }

The distance at which the gravity strength is equal to Area2D.Gravity. For example, on a planet 100 pixels in radius with a surface gravity of 4.0 px/s², set the Area2D.Gravity to 4.0 and the unit distance to 100.0. The gravity will have falloff according to the inverse square law, so in the example, at 200 pixels from the center the gravity will be 1.0 px/s² (twice the distance, 1/4th the gravity), at 50 pixels it will be 16.0 px/s² (half the distance, 4× the gravity), and so on. The above is true only when the unit distance is a positive number. When this is set to 0.0, the gravity will be constant regardless of distance.

GravitySpaceOverrideProperty
# GravitySpaceOverride
C#
public Area2D.SpaceOverride GravitySpaceOverride { get; set; }

Controls combining area gravity with other fields/the world. Gravity = 0 while Disabled does not enable zero gravity; choose an appropriate replacement mode.

LinearDampProperty
# LinearDamp
C#
public float LinearDamp { get; set; }

The rate at which objects stop moving in this area. Represents the linear velocity lost per second. See ProjectSettings.physics/2d/default_linear_damp for more details about damping.

LinearDampSpaceOverrideProperty
# LinearDampSpaceOverride
C#
public Area2D.SpaceOverride LinearDampSpaceOverride { get; set; }

Override mode for linear damping calculations within this area.

MonitorableProperty
# Monitorable
C#
public bool Monitorable { get; set; }

Allows other monitoring areas to detect this Area2D. It does not enable this area's own Monitoring. Defer changes in locked physics callbacks.

MonitoringProperty
# Monitoring
C#
public bool Monitoring { get; set; }

Enables this area to detect bodies and areas. Distinct from Monitorable. Change through SetDeferred inside enter/exit handlers because direct changes are blocked during notification.

PriorityProperty
# Priority
C#
public int Priority { get; set; }

The area's priority. Higher priority areas are processed first. The World2D's physics is always processed last, after all areas.

Methods36

GetAngularDampfloat
# GetAngularDamp
C#
public float GetAngularDamp();
Returns float
GetAngularDampSpaceOverrideModeArea2D.SpaceOverride
# GetAngularDampSpaceOverrideMode
C#
public Area2D.SpaceOverride GetAngularDampSpaceOverrideMode();
Returns Area2D.SpaceOverride
GetAudioBusNameStringName
# GetAudioBusName
C#
public StringName GetAudioBusName();
Returns StringName
GetGravityfloat
# GetGravity
C#
public float GetGravity();
Returns float
GetGravityDirectionVector2
# GetGravityDirection
C#
public Vector2 GetGravityDirection();
Returns Vector2
GetGravityPointCenterVector2
# GetGravityPointCenter
C#
public Vector2 GetGravityPointCenter();
Returns Vector2
GetGravityPointUnitDistancefloat
# GetGravityPointUnitDistance
C#
public float GetGravityPointUnitDistance();
Returns float
GetGravitySpaceOverrideModeArea2D.SpaceOverride
# GetGravitySpaceOverrideMode
C#
public Area2D.SpaceOverride GetGravitySpaceOverrideMode();
Returns Area2D.SpaceOverride
GetLinearDampfloat
# GetLinearDamp
C#
public float GetLinearDamp();
Returns float
GetLinearDampSpaceOverrideModeArea2D.SpaceOverride
# GetLinearDampSpaceOverrideMode
C#
public Area2D.SpaceOverride GetLinearDampSpaceOverrideMode();
Returns Area2D.SpaceOverride
GetOverlappingAreasReckfell.Collections.Array<Area2D>
# GetOverlappingAreas
C#
public Reckfell.Collections.Array<Area2D> GetOverlappingAreas();

Returns a list of intersecting Area2Ds. The overlapping area's CollisionObject2D.CollisionLayer must be part of this area's CollisionObject2D.CollisionMask in order to be detected. 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.

Returns Reckfell.Collections.Array<Area2D>
GetOverlappingBodiesReckfell.Collections.Array<Entity2D>
# GetOverlappingBodies
C#
public Reckfell.Collections.Array<Entity2D> GetOverlappingBodies();

Returns detected bodies from physics-updated state. Immediately after moving or adding a shape, the list may still be old. Requires Monitoring=true; use BodyEntered for entry reactions.

Returns Reckfell.Collections.Array<Entity2D>

Entity2D array of currently detected bodies. No overlaps can produce an empty array; with Monitoring disabled the method reports an error and also returns an empty array.

GetPriorityint
# GetPriority
C#
public int GetPriority();
Returns int
HasOverlappingAreasbool
# HasOverlappingAreas
C#
public bool HasOverlappingAreas();

Returns true if intersecting any Area2Ds, otherwise returns false. The overlapping area's CollisionObject2D.CollisionLayer must be part of this area's CollisionObject2D.CollisionMask in order to be detected. For performance reasons (collisions are all processed at the same time) the list of overlapping areas is modified once during the physics step, not immediately after objects are moved. Consider using signals instead.

Returns bool
HasOverlappingBodiesbool
# HasOverlappingBodies
C#
public bool HasOverlappingBodies();

Returns true if intersecting any PhysicsBody2Ds or TileMaps, otherwise returns false. The overlapping body's CollisionObject2D.CollisionLayer must be part of this area's CollisionObject2D.CollisionMask in order to be detected. For performance reasons (collisions are all processed at the same time) the list of overlapping bodies is modified once during the physics step, not immediately after objects are moved. Consider using signals instead.

Returns bool
IsGravityAPointbool
# IsGravityAPoint
C#
public bool IsGravityAPoint();
Returns bool
IsMonitorablebool
# IsMonitorable
C#
public bool IsMonitorable();
Returns bool
IsMonitoringbool
# IsMonitoring
C#
public bool IsMonitoring();
Returns bool
IsOverridingAudioBusbool
# IsOverridingAudioBus
C#
public bool IsOverridingAudioBus();
Returns bool
OverlapsAreabool
# OverlapsArea
C#
public bool OverlapsArea(Entity area);

Returns true if the given Area2D intersects or overlaps this Area2D, false otherwise. Note: The result of this test is not immediate after moving objects. For performance, the list of overlaps is updated once per frame and before the physics step. Consider using signals instead.

Parameters
NameTypeDefault
areaEntity—
Returns bool
OverlapsBodybool
# OverlapsBody
C#
public bool OverlapsBody(Entity body);

Returns true if the given physics body intersects or overlaps this Area2D, false otherwise. 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 bodies themselves, they register their tiles with collision shapes as a virtual physics body.

Parameters
NameTypeDefault
bodyEntity—
Returns bool
SetAngularDampvoid
# SetAngularDamp
C#
public void SetAngularDamp(float angularDamp);
Parameters
NameTypeDefault
angularDampfloat—
SetAngularDampSpaceOverrideModevoid
# SetAngularDampSpaceOverrideMode
C#
public void SetAngularDampSpaceOverrideMode(Area2D.SpaceOverride spaceOverrideMode);
Parameters
NameTypeDefault
spaceOverrideModeArea2D.SpaceOverride—
SetAudioBusNamevoid
# SetAudioBusName
C#
public void SetAudioBusName(StringName name);
Parameters
NameTypeDefault
nameStringName—
SetAudioBusOverridevoid
# SetAudioBusOverride
C#
public void SetAudioBusOverride(bool enable);
Parameters
NameTypeDefault
enablebool—
SetGravityvoid
# SetGravity
C#
public void SetGravity(float gravity);
Parameters
NameTypeDefault
gravityfloat—
SetGravityDirectionvoid
# SetGravityDirection
C#
public void SetGravityDirection(Vector2 direction);
Parameters
NameTypeDefault
directionVector2—
SetGravityIsPointvoid
# SetGravityIsPoint
C#
public void SetGravityIsPoint(bool enable);
Parameters
NameTypeDefault
enablebool—
SetGravityPointCentervoid
# SetGravityPointCenter
C#
public void SetGravityPointCenter(Vector2 center);
Parameters
NameTypeDefault
centerVector2—
SetGravityPointUnitDistancevoid
# SetGravityPointUnitDistance
C#
public void SetGravityPointUnitDistance(float distanceScale);
Parameters
NameTypeDefault
distanceScalefloat—
SetGravitySpaceOverrideModevoid
# SetGravitySpaceOverrideMode
C#
public void SetGravitySpaceOverrideMode(Area2D.SpaceOverride spaceOverrideMode);
Parameters
NameTypeDefault
spaceOverrideModeArea2D.SpaceOverride—
SetLinearDampvoid
# SetLinearDamp
C#
public void SetLinearDamp(float linearDamp);
Parameters
NameTypeDefault
linearDampfloat—
SetLinearDampSpaceOverrideModevoid
# SetLinearDampSpaceOverrideMode
C#
public void SetLinearDampSpaceOverrideMode(Area2D.SpaceOverride spaceOverrideMode);
Parameters
NameTypeDefault
spaceOverrideModeArea2D.SpaceOverride—
SetMonitorablevoid
# SetMonitorable
C#
public void SetMonitorable(bool enable);
Parameters
NameTypeDefault
enablebool—
SetMonitoringvoid
# SetMonitoring
C#
public void SetMonitoring(bool enable);
Parameters
NameTypeDefault
enablebool—
SetPriorityvoid
# SetPriority
C#
public void SetPriority(int priority);
Parameters
NameTypeDefault
priorityint—

Signals and events8

AreaEnteredEvent
# AreaEntered
C#
public event Area2D.AreaEnteredEventHandler AreaEntered;

Emitted when the received area enters this area. Requires Area2D.Monitoring to be set to true.

Handler parameters
NameTypeDefault
areaArea2D—
AreaExitedEvent
# AreaExited
C#
public event Area2D.AreaExitedEventHandler AreaExited;

Emitted when the received area exits this area. Requires Area2D.Monitoring to be set to true.

Handler parameters
NameTypeDefault
areaArea2D—
AreaShapeEnteredEvent
# AreaShapeEntered
C#
public event Area2D.AreaShapeEnteredEventHandler AreaShapeEntered;

Emitted when a Shape2D of the received area enters a shape of this area. Requires Area2D.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 PhysicsServer2D. Example: Get the CollisionShape2D node from the shape index:

Handler parameters
NameTypeDefault
areaRidRid—
areaArea2D—
areaShapeIndexlong—
localShapeIndexlong—
AreaShapeExitedEvent
# AreaShapeExited
C#
public event Area2D.AreaShapeExitedEventHandler AreaShapeExited;

Emitted when a Shape2D of the received area exits a shape of this area. Requires Area2D.Monitoring to be set to true. See also Area2D.AreaShapeEntered.

Handler parameters
NameTypeDefault
areaRidRid—
areaArea2D—
areaShapeIndexlong—
localShapeIndexlong—
BodyEnteredEvent
# BodyEntered
C#
public event Area2D.BodyEnteredEventHandler BodyEntered;

Emitted when the received body enters this area. body can be a PhysicsBody2D or a TileMap. TileMaps are detected if their TileSet has collision shapes configured. Requires Area2D.Monitoring to be set to true.

Handler parameters
NameTypeDefault
bodyEntity2D—
BodyExitedEvent
# BodyExited
C#
public event Area2D.BodyExitedEventHandler BodyExited;

Emitted when the received body exits this area. body can be a PhysicsBody2D or a TileMap. TileMaps are detected if their TileSet has collision shapes configured. Requires Area2D.Monitoring to be set to true.

Handler parameters
NameTypeDefault
bodyEntity2D—
BodyShapeEnteredEvent
# BodyShapeEntered
C#
public event Area2D.BodyShapeEnteredEventHandler BodyShapeEntered;

Emitted when a Shape2D of the received body enters a shape of this area. body can be a PhysicsBody2D or a TileMap. TileMaps are detected if their TileSet has collision shapes configured. Requires Area2D.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 PhysicsServer2D. Example: Get the CollisionShape2D node from the shape index:

Handler parameters
NameTypeDefault
bodyRidRid—
bodyEntity2D—
bodyShapeIndexlong—
localShapeIndexlong—
BodyShapeExitedEvent
# BodyShapeExited
C#
public event Area2D.BodyShapeExitedEventHandler BodyShapeExited;

Emitted when a Shape2D of the received body exits a shape of this area. body can be a PhysicsBody2D or a TileMap. TileMaps are detected if their TileSet has collision shapes configured. Requires Area2D.Monitoring to be set to true. See also Area2D.BodyShapeEntered.

Handler parameters
NameTypeDefault
bodyRidRid—
bodyEntity2D—
bodyShapeIndexlong—
localShapeIndexlong—

Area2D.SpaceOverride

ValueDescription
Combine = 1

This area adds its gravity/damping values to whatever has been calculated so far (in Area2D.Priority order).

CombineReplace = 2

This area adds its gravity/damping values to whatever has been calculated so far (in Area2D.Priority order), ignoring any lower priority areas.

Disabled = 0

This area does not affect gravity/damping.

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 Area2D.Priority order), but keeps calculating the rest of the areas.

Reckfell Engine documentationBack to top ↑
QUICK LINKSGetting startedEntity hierarchyC# & .NET 10Scenes and prefabs
Reckfell guides and full API K
reckfellENGINE
RECKFELL ACCOUNT

Sign in

Sign in to your Reckfell account.

One account for the entire Reckfell platform.