reckfellENGINE

CollisionObject2D

A base 2D physics collision object.

On this page
class CollisionObject2DReckfellSharpInherits Entity2D

Bodies and areas inherit CollisionObject2D. Child CollisionShapes and Shape resources define geometry; visible sprites/meshes do not create it automatically. Layer defines membership; Mask filters detection/interaction.

Layer number 3 corresponds to bit value 4. SetCollisionLayerValue/SetCollisionMaskValue accept a number from 1–32, not a bitmask. Use GetRid for ray exclusion, not GetInstanceId. A query shape index refers to physics shapes, not an arbitrary hierarchy child index.

Guide and example.

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

Properties5

CollisionLayerProperty
# CollisionLayer
C#
public uint CollisionLayer { get; set; }

Bitmask of object membership in 2D physics layers. Layer 3 has value 4; mask 3 includes layers 1 and 2. Distinct from the CollisionMask filter.

CollisionMaskProperty
# CollisionMask
C#
public uint CollisionMask { get; set; }

Bitmask filtering interaction or detection. For Area2D it selects detected-body layers; body contact does not require identical reciprocal masks. Rays and navigation have separate filters.

CollisionPriorityProperty
# CollisionPriority
C#
public float CollisionPriority { get; set; }

The priority used to solve colliding when occurring penetration. The higher the priority is, the lower the penetration into the object will be. This can for example be used to prevent the player from breaking through the boundaries of a level.

DisableModeProperty
# DisableMode
C#
public CollisionObject2D.DisableModeEnum DisableMode { get; set; }

Defines the behavior in physics when Entity.ProcessMode is set to Entity.ProcessModeEnum.Disabled.

InputPickableProperty
# InputPickable
C#
public bool InputPickable { get; set; }

If true, this object is pickable. A pickable object can detect the mouse pointer entering/leaving, and if the mouse is inside it, report input events. Requires at least one CollisionObject2D.CollisionLayer bit to be set.

Methods41

CreateShapeOwneruint
# CreateShapeOwner
C#
public uint CreateShapeOwner(ReckfellObject owner);

Creates a new shape owner for the given object. Returns owner_id of the new owner for future reference.

Parameters
NameTypeDefault
ownerReckfellObject—
Returns uint
GetCollisionLayeruint
# GetCollisionLayer
C#
public uint GetCollisionLayer();
Returns uint
GetCollisionLayerValuebool
# GetCollisionLayerValue
C#
public bool GetCollisionLayerValue(int layerNumber);

Tests one membership bit by layer number 1–32, not an assembled bitmask.

Parameters
NameTypeDefault
layerNumberint—
layerNumber

Layer number from 1 through 32. Number 3 selects the bit with value 4.

Returns bool

true if the selected bit is set; false if cleared. An invalid number reports an error and returns false.

GetCollisionMaskuint
# GetCollisionMask
C#
public uint GetCollisionMask();
Returns uint
GetCollisionMaskValuebool
# GetCollisionMaskValue
C#
public bool GetCollisionMaskValue(int layerNumber);

Tests one filter bit by layer number 1–32, not an assembled bitmask.

Parameters
NameTypeDefault
layerNumberint—
layerNumber

Layer number from 1 through 32. Number 3 selects the bit with value 4.

Returns bool

true if the selected bit is set; false if cleared. An invalid number reports an error and returns false.

GetCollisionPriorityfloat
# GetCollisionPriority
C#
public float GetCollisionPriority();
Returns float
GetDisableModeCollisionObject2D.DisableModeEnum
# GetDisableMode
C#
public CollisionObject2D.DisableModeEnum GetDisableMode();
Returns CollisionObject2D.DisableModeEnum
GetRidRid
# GetRid
C#
public Rid GetRid();

Returns the object's Rid.

Returns Rid
GetShapeOwnerOneWayCollisionDirectionVector2
# GetShapeOwnerOneWayCollisionDirection
C#
public Vector2 GetShapeOwnerOneWayCollisionDirection(uint ownerId);

Returns the one_way_collision_direction of the shape owner identified by the given owner_id.

Parameters
NameTypeDefault
ownerIduint—
Returns Vector2
GetShapeOwnerOneWayCollisionMarginfloat
# GetShapeOwnerOneWayCollisionMargin
C#
public float GetShapeOwnerOneWayCollisionMargin(uint ownerId);

Returns the one_way_collision_margin of the shape owner identified by given owner_id.

Parameters
NameTypeDefault
ownerIduint—
Returns float
GetShapeOwnersint[]
# GetShapeOwners
C#
public int[] GetShapeOwners();

Returns an Reckfell.Collections.Array of owner_id identifiers. You can use these ids in other methods that take owner_id as an argument.

Returns int[]
IsPickablebool
# IsPickable
C#
public bool IsPickable();
Returns bool
IsShapeOwnerDisabledbool
# IsShapeOwnerDisabled
C#
public bool IsShapeOwnerDisabled(uint ownerId);

If true, the shape owner and its shapes are disabled.

Parameters
NameTypeDefault
ownerIduint—
Returns bool
IsShapeOwnerOneWayCollisionEnabledbool
# IsShapeOwnerOneWayCollisionEnabled
C#
public bool IsShapeOwnerOneWayCollisionEnabled(uint ownerId);

Returns true if collisions for the shape owner originating from this CollisionObject2D will not be reported to collided with CollisionObject2Ds.

Parameters
NameTypeDefault
ownerIduint—
Returns bool
RemoveShapeOwnervoid
# RemoveShapeOwner
C#
public void RemoveShapeOwner(uint ownerId);

Removes the given shape owner.

Parameters
NameTypeDefault
ownerIduint—
SetCollisionLayervoid
# SetCollisionLayer
C#
public void SetCollisionLayer(uint layer);
Parameters
NameTypeDefault
layeruint—
SetCollisionLayerValuevoid
# SetCollisionLayerValue
C#
public void SetCollisionLayerValue(int layerNumber, bool value);

Changes one membership bit while preserving the others. Assign the CollisionLayer property to replace the entire mask.

Parameters
NameTypeDefault
layerNumberint—
valuebool—
layerNumber

Layer number 1–32, not a mask value. Out-of-range changes are rejected with an error message.

value

true sets the selected bit; false clears it.

SetCollisionMaskvoid
# SetCollisionMask
C#
public void SetCollisionMask(uint mask);
Parameters
NameTypeDefault
maskuint—
SetCollisionMaskValuevoid
# SetCollisionMaskValue
C#
public void SetCollisionMaskValue(int layerNumber, bool value);

Changes one filter bit while preserving the others. Assign the CollisionMask property to replace the entire mask.

Parameters
NameTypeDefault
layerNumberint—
valuebool—
layerNumber

Layer number 1–32, not a mask value. Out-of-range changes are rejected with an error message.

value

true sets the selected bit; false clears it.

SetCollisionPriorityvoid
# SetCollisionPriority
C#
public void SetCollisionPriority(float priority);
Parameters
NameTypeDefault
priorityfloat—
SetDisableModevoid
# SetDisableMode
C#
public void SetDisableMode(CollisionObject2D.DisableModeEnum mode);
Parameters
NameTypeDefault
modeCollisionObject2D.DisableModeEnum—
SetPickablevoid
# SetPickable
C#
public void SetPickable(bool enabled);
Parameters
NameTypeDefault
enabledbool—
ShapeFindOwneruint
# ShapeFindOwner
C#
public uint ShapeFindOwner(int shapeIndex);

Returns the owner_id of the given shape.

Parameters
NameTypeDefault
shapeIndexint—
Returns uint
ShapeOwnerAddShapevoid
# ShapeOwnerAddShape
C#
public void ShapeOwnerAddShape(uint ownerId, Shape2D shape);

Adds a Shape2D to the shape owner.

Parameters
NameTypeDefault
ownerIduint—
shapeShape2D—
ShapeOwnerClearShapesvoid
# ShapeOwnerClearShapes
C#
public void ShapeOwnerClearShapes(uint ownerId);

Removes all shapes from the shape owner.

Parameters
NameTypeDefault
ownerIduint—
ShapeOwnerGetOwnerReckfellObject
# ShapeOwnerGetOwner
C#
public ReckfellObject ShapeOwnerGetOwner(uint ownerId);

Returns the parent object of the given shape owner.

Parameters
NameTypeDefault
ownerIduint—
Returns ReckfellObject
ShapeOwnerGetShapeShape2D
# ShapeOwnerGetShape
C#
public Shape2D ShapeOwnerGetShape(uint ownerId, int shapeId);

Returns the Shape2D with the given ID from the given shape owner.

Parameters
NameTypeDefault
ownerIduint—
shapeIdint—
Returns Shape2D
ShapeOwnerGetShapeCountint
# ShapeOwnerGetShapeCount
C#
public int ShapeOwnerGetShapeCount(uint ownerId);

Returns the number of shapes the given shape owner contains.

Parameters
NameTypeDefault
ownerIduint—
Returns int
ShapeOwnerGetShapeIndexint
# ShapeOwnerGetShapeIndex
C#
public int ShapeOwnerGetShapeIndex(uint ownerId, int shapeId);

Returns the child index of the Shape2D with the given ID from the given shape owner.

Parameters
NameTypeDefault
ownerIduint—
shapeIdint—
Returns int
ShapeOwnerGetTransformTransform2D
# ShapeOwnerGetTransform
C#
public Transform2D ShapeOwnerGetTransform(uint ownerId);

Returns the shape owner's Transform2D.

Parameters
NameTypeDefault
ownerIduint—
Returns Transform2D
ShapeOwnerRemoveShapevoid
# ShapeOwnerRemoveShape
C#
public void ShapeOwnerRemoveShape(uint ownerId, int shapeId);

Removes a shape from the given shape owner.

Parameters
NameTypeDefault
ownerIduint—
shapeIdint—
ShapeOwnerSetDisabledvoid
# ShapeOwnerSetDisabled
C#
public void ShapeOwnerSetDisabled(uint ownerId, bool disabled);

If true, disables the given shape owner.

Parameters
NameTypeDefault
ownerIduint—
disabledbool—
ShapeOwnerSetOneWayCollisionvoid
# ShapeOwnerSetOneWayCollision
C#
public void ShapeOwnerSetOneWayCollision(uint ownerId, bool enable);

If enable is true, collisions for the shape owner originating from this CollisionObject2D will not be reported to collided with CollisionObject2Ds.

Parameters
NameTypeDefault
ownerIduint—
enablebool—
ShapeOwnerSetOneWayCollisionDirectionvoid
# ShapeOwnerSetOneWayCollisionDirection
C#
public void ShapeOwnerSetOneWayCollisionDirection(uint ownerId, Vector2 direction);

Sets the one_way_collision_direction of the shape owner identified by the given owner_id to direction.

Parameters
NameTypeDefault
ownerIduint—
directionVector2—
ShapeOwnerSetOneWayCollisionMarginvoid
# ShapeOwnerSetOneWayCollisionMargin
C#
public void ShapeOwnerSetOneWayCollisionMargin(uint ownerId, float margin);

Sets the one_way_collision_margin of the shape owner identified by given owner_id to margin pixels.

Parameters
NameTypeDefault
ownerIduint—
marginfloat—
ShapeOwnerSetTransformvoid
# ShapeOwnerSetTransform
C#
public void ShapeOwnerSetTransform(uint ownerId, Transform2D transform);

Sets the Transform2D of the given shape owner.

Parameters
NameTypeDefault
ownerIduint—
transformTransform2D—
_InputEventvoid
# _InputEvent
C#
public virtual void _InputEvent(Viewport viewport, InputEvent @event, int shapeIdx);

Detects unhandled mouse and touch InputEvents through event when they happen while hovering over the object. Gesture events are not detected. viewport is the Viewport that the event originated in (for viewports other than the main one to be detected, Viewport.PhysicsObjectPicking needs to be set to true). shape_idx is the index of the detected shape from PhysicsServer2D. See also Entity._UnhandledInput, CollisionObject2D.ShapeFindOwner, and CollisionObject2D.ShapeOwnerGetOwner. Note: InputEventScreenDrag events are triggered if the drag events started while hovering the object, or when the object is in the path of the drag event. Note: CollisionObject2D.InputEvent requires CollisionObject2D.InputPickable to be true and at least one CollisionObject2D.CollisionLayer bit to be set.

Parameters
NameTypeDefault
viewportViewport—
eventInputEvent—
shapeIdxint—
_MouseEntervoid
# _MouseEnter
C#
public virtual void _MouseEnter();

Called when the mouse pointer enters any of this object's shapes. Requires CollisionObject2D.InputPickable to be true and at least one CollisionObject2D.CollisionLayer bit to be set. Note that moving between different shapes within a single CollisionObject2D won't cause this function to be called.

_MouseExitvoid
# _MouseExit
C#
public virtual void _MouseExit();

Called when the mouse pointer exits all this object's shapes. Requires CollisionObject2D.InputPickable to be true and at least one CollisionObject2D.CollisionLayer bit to be set. Note that moving between different shapes within a single CollisionObject2D won't cause this function to be called.

_MouseShapeEntervoid
# _MouseShapeEnter
C#
public virtual void _MouseShapeEnter(int shapeIdx);

Called when the mouse pointer enters any of this object's shapes or moves from one shape to another. shape_idx is the child index of the newly entered Shape2D. Requires CollisionObject2D.InputPickable to be true and at least one CollisionObject2D.CollisionLayer bit to be called.

Parameters
NameTypeDefault
shapeIdxint—
_MouseShapeExitvoid
# _MouseShapeExit
C#
public virtual void _MouseShapeExit(int shapeIdx);

Called when the mouse pointer exits any of this object's shapes. shape_idx is the child index of the exited Shape2D. Requires CollisionObject2D.InputPickable to be true and at least one CollisionObject2D.CollisionLayer bit to be called.

Parameters
NameTypeDefault
shapeIdxint—

Signals and events5

InputEventEvent
# InputEvent
C#
public event CollisionObject2D.InputEventEventHandler InputEvent;

Detects unhandled mouse and touch InputEvents through event when they happen while hovering over the object. Gesture events are not detected. viewport is the Viewport that the event originated in (for viewports other than the main one to be detected, Viewport.PhysicsObjectPicking needs to be set to true). shape_idx is the index of the detected shape from PhysicsServer2D. See also Entity._UnhandledInput, CollisionObject2D.ShapeFindOwner, and CollisionObject2D.ShapeOwnerGetOwner. Note: InputEventScreenDrag events are triggered if the drag events started while hovering the object, or when the object is in the path of the drag event. Note: CollisionObject2D.InputEvent requires CollisionObject2D.InputPickable to be true and at least one CollisionObject2D.CollisionLayer bit to be set.

Handler parameters
NameTypeDefault
viewportEntity—
eventInputEvent—
shapeIdxlong—
MouseEnteredEvent
# MouseEntered
C#
public event Action MouseEntered;

Emitted when the mouse pointer enters any of this object's shapes. Requires CollisionObject2D.InputPickable to be true and at least one CollisionObject2D.CollisionLayer bit to be set. Note that moving between different shapes within a single CollisionObject2D won't cause this signal to be emitted. Note: Due to the lack of continuous collision detection, this signal may not be emitted in the expected order if the mouse moves fast enough and the CollisionObject2D's area is small. This signal may also not be emitted if another CollisionObject2D is overlapping the CollisionObject2D in question.

MouseExitedEvent
# MouseExited
C#
public event Action MouseExited;

Emitted when the mouse pointer exits all this object's shapes. Requires CollisionObject2D.InputPickable to be true and at least one CollisionObject2D.CollisionLayer bit to be set. Note that moving between different shapes within a single CollisionObject2D won't cause this signal to be emitted. Note: Due to the lack of continuous collision detection, this signal may not be emitted in the expected order if the mouse moves fast enough and the CollisionObject2D's area is small. This signal may also not be emitted if another CollisionObject2D is overlapping the CollisionObject2D in question.

MouseShapeEnteredEvent
# MouseShapeEntered
C#
public event CollisionObject2D.MouseShapeEnteredEventHandler MouseShapeEntered;

Emitted when the mouse pointer enters any of this object's shapes or moves from one shape to another. shape_idx is the child index of the newly entered Shape2D. Requires CollisionObject2D.InputPickable to be true and at least one CollisionObject2D.CollisionLayer bit to be set.

Handler parameters
NameTypeDefault
shapeIdxlong—
MouseShapeExitedEvent
# MouseShapeExited
C#
public event CollisionObject2D.MouseShapeExitedEventHandler MouseShapeExited;

Emitted when the mouse pointer exits any of this object's shapes. shape_idx is the child index of the exited Shape2D. Requires CollisionObject2D.InputPickable to be true and at least one CollisionObject2D.CollisionLayer bit to be set.

Handler parameters
NameTypeDefault
shapeIdxlong—

CollisionObject2D.DisableModeEnum

ValueDescription
KeepActive = 2

When Entity.ProcessMode is set to Entity.ProcessModeEnum.Disabled, do not affect the physics simulation.

MakeStatic = 1

When Entity.ProcessMode is set to Entity.ProcessModeEnum.Disabled, make the body static. Doesn't affect Area2D. PhysicsBody2D can't be affected by forces or other bodies while static. Automatically set PhysicsBody2D back to its original mode when the Entity is processed again.

Remove = 0

When Entity.ProcessMode is set to Entity.ProcessModeEnum.Disabled, remove from the physics simulation to stop all physics interactions with this CollisionObject2D. Automatically re-added to the physics simulation when the Entity is processed again.

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.