Base node for 2D collision objects.
    public abstract class CollisionObject2D : Node2D

CollisionObject2D is the base class for 2D physics objects. It can hold any number of 2D collision Shape2Ds. Each shape must be assigned to a shape owner. The CollisionObject2D can have any number of shape owners. Shape owners are not nodes and do not appear in the editor, but are accessible through code using the shape_owner_* methods.

Inheritance Chain

Derived Classes

Signals

    "input_event" (Node viewport, InputEvent event, int shape_idx)

Emitted when an input event occurs. Requires InputPickable to be true and at least one collision_layer bit to be set. See _InputEvent(Godot.Object, Godot.InputEvent, int) for details.

    "mouse_entered" ()

Emitted when the mouse pointer enters any of this object’s shapes. Requires InputPickable to be true and at least one collision_layer bit to be set.

    "mouse_exited" ()

Emitted when the mouse pointer exits all this object’s shapes. Requires InputPickable to be true and at least one collision_layer bit to be set.

Properties

    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 collision_layer bit to be set.

Methods

    public virtual void _InputEvent(Object viewport, InputEvent @event, int shapeIdx)

Accepts unhandled InputEvents. Requires InputPickable to be true. shapeIdx is the child index of the clicked Shape2D. Connect to the input_event signal to easily pick up these events.

    public uint CreateShapeOwner(Object owner)

    public RID GetRid()

Returns the object’s RID.

    public float GetShapeOwnerOneWayCollisionMargin(uint ownerId)

    public Godot.Collections.Array GetShapeOwners()

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

    [Obsolete("IsPickable is deprecated. Use the InputPickable property instead.")]
    public bool IsPickable()

Getter for InputPickable

    public bool IsShapeOwnerDisabled(uint ownerId)

    public bool IsShapeOwnerOneWayCollisionEnabled(uint ownerId)

    public void RemoveShapeOwner(uint ownerId)

    [Obsolete("SetPickable is deprecated. Use the InputPickable property instead.")]
    public void SetPickable(bool enabled)

Setter for InputPickable

    public uint ShapeFindOwner(int shapeIndex)

    public void ShapeOwnerAddShape(uint ownerId, Shape2D shape)

    public void ShapeOwnerClearShapes(uint ownerId)

    public Object ShapeOwnerGetOwner(uint ownerId)

    public Shape2D ShapeOwnerGetShape(uint ownerId, int shapeId)

    public int ShapeOwnerGetShapeCount(uint ownerId)

    public int ShapeOwnerGetShapeIndex(uint ownerId, int shapeId)

    public Transform2D ShapeOwnerGetTransform(uint ownerId)

    public void ShapeOwnerRemoveShape(uint ownerId, int shapeId)

    public void ShapeOwnerSetDisabled(uint ownerId, bool disabled)

    public void ShapeOwnerSetOneWayCollision(uint ownerId, bool enable)

    public void ShapeOwnerSetOneWayCollisionMargin(uint ownerId, float margin)

    public void ShapeOwnerSetTransform(uint ownerId, Transform2D transform)
Tags: