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" (Object viewport, Object event, int shape_idx)

Emitted when an input event occurs and input_pickable is true. See _InputEvent(Godot.Object, Godot.InputEvent, int) for details.

    "mouse_entered" ()

Emitted when the mouse pointer enters any of this object’s shapes.

    "mouse_exited" ()

Emitted when the mouse pointer exits all this object’s shapes.

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.

Methods

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

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

    public int CreateShapeOwner(Object owner)

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

    public RID GetRid()

Returns the object’s RID.

    public object[] GetShapeOwners()

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

    public bool IsPickable()

Getter for InputPickable

    public bool IsShapeOwnerDisabled(int ownerId)

If true the shape owner and its shapes are disabled.

    public bool IsShapeOwnerOneWayCollisionEnabled(int ownerId)

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

    public void RemoveShapeOwner(int ownerId)

Removes the given shape owner.

    public void SetPickable(bool enabled)

Setter for InputPickable

    public int ShapeFindOwner(int shapeIndex)

Returns the owner_id of the given shape.

    public void ShapeOwnerAddShape(int ownerId, Shape2D shape)

Adds a Shape2D to the shape owner.

    public void ShapeOwnerClearShapes(int ownerId)

Removes all shapes from the shape owner.

    public Object ShapeOwnerGetOwner(int ownerId)

Returns the parent object of the given shape owner.

    public Shape2D ShapeOwnerGetShape(int ownerId, int shapeId)

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

    public int ShapeOwnerGetShapeCount(int ownerId)

Returns the number of shapes the given shape owner contains.

    public int ShapeOwnerGetShapeIndex(int ownerId, int shapeId)

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

    public Transform2D ShapeOwnerGetTransform(int ownerId)

Returns the shape owner’s Transform2D.

    public void ShapeOwnerRemoveShape(int ownerId, int shapeId)

Removes a shape from the given shape owner.

    public void ShapeOwnerSetDisabled(int ownerId, bool disabled)

If true disables the given shape owner.

    public void ShapeOwnerSetOneWayCollision(int ownerId, bool enable)

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

    public void ShapeOwnerSetTransform(int ownerId, Transform2D transform)

Sets the Transform2D of the given shape owner.

Tags: