Struct CollisionObject2D

Base node for 2D collision objects.

struct CollisionObject2D ;

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.

Properties

NameTypeDescription
inputPickable[get, set] boolIf 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

NameDescription
_inputEvent Accepts unhandled InputEvents. Requires inputPickable to be true. shape_idx is the child index of the clicked Shape2D. Connect to the input_event signal to easily pick up these events.
createShapeOwner Creates a new shape owner for the given object. Returns owner_id of the new owner for future reference.
getRid Returns the object's RID.
getShapeOwnerOneWayCollisionMargin Returns the one_way_collision_margin of the shape owner identified by given owner_id.
getShapeOwners Returns an Array of owner_id identifiers. You can use these ids in other methods that take owner_id as an argument.
isPickable
isShapeOwnerDisabled If true, the shape owner and its shapes are disabled.
isShapeOwnerOneWayCollisionEnabled Returns true if collisions for the shape owner originating from this CollisionObject2D will not be reported to collided with CollisionObject2Ds.
removeShapeOwner Removes the given shape owner.
setPickable
shapeFindOwner Returns the owner_id of the given shape.
shapeOwnerAddShape Adds a Shape2D to the shape owner.
shapeOwnerClearShapes Removes all shapes from the shape owner.
shapeOwnerGetOwner Returns the parent object of the given shape owner.
shapeOwnerGetShape Returns the Shape2D with the given id from the given shape owner.
shapeOwnerGetShapeCount Returns the number of shapes the given shape owner contains.
shapeOwnerGetShapeIndex Returns the child index of the Shape2D with the given id from the given shape owner.
shapeOwnerGetTransform Returns the shape owner's Transform2D.
shapeOwnerRemoveShape Removes a shape from the given shape owner.
shapeOwnerSetDisabled If true, disables the given shape owner.
shapeOwnerSetOneWayCollision If enable is true, collisions for the shape owner originating from this CollisionObject2D will not be reported to collided with CollisionObject2Ds.
shapeOwnerSetOneWayCollisionMargin Sets the one_way_collision_margin of the shape owner identified by given owner_id to margin pixels.
shapeOwnerSetTransform Sets the Transform2D of the given shape owner.