Base node for 2D collision objects.
CollisionObject2D is the base class for 2D physics objects. It can hold any number of 2D collision [Shape2D]s. Each shape must be assigned to a [i]shape owner[/i]. 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 [code]shape_owner_*[/code] methods.
Accepts unhandled [InputEvent]s. Requires [member input_pickable] to be [code]true[/code]. [code]shape_idx[/code] is the child index of the clicked [Shape2D]. Connect to the [code]input_event[/code] signal to easily pick up these events.
Creates a new shape owner for the given object. Returns [code]owner_id[/code] of the new owner for future reference.
Returns whether or not the specified [code]bit[/code] of the [member collision_layer] is set.
Returns whether or not the specified [code]bit[/code] of the [member collision_mask] is set.
Returns the object's [RID].
Returns the [code]one_way_collision_margin[/code] of the shape owner identified by given [code]owner_id[/code].
Returns an [Array] of [code]owner_id[/code] identifiers. You can use these ids in other methods that take [code]owner_id[/code] as an argument.
If [code]true[/code], the shape owner and its shapes are disabled.
Returns [code]true[/code] if collisions for the shape owner originating from this [CollisionObject2D] will not be reported to collided with [CollisionObject2D]s.
Removes the given shape owner.
Returns the [code]owner_id[/code] of the given shape.
If [code]value[/value] is [code]true[/code], sets the specified [code]bit[/code] in the the [member collision_layer].
If [code]value[/value] is [code]false[/code], clears the specified [code]bit[/code] in the the [member collision_layer].
If [code]value[/value] is [code]true[/code], sets the specified [code]bit[/code] in the the [member collision_mask].
If [code]value[/value] is [code]false[/code], clears the specified [code]bit[/code] in the the [member collision_mask].
Adds a [Shape2D] to the shape owner.
Removes all shapes from the shape owner.
Returns the parent object of the given shape owner.
Returns the [Shape2D] with the given id from the given shape owner.
Returns the number of shapes the given shape owner contains.
Returns the child index of the [Shape2D] with the given id from the given shape owner.
Returns the shape owner's [Transform2D].
Removes a shape from the given shape owner.
If [code]true[/code], disables the given shape owner.
If [code]enable[/code] is [code]true[/code], collisions for the shape owner originating from this [CollisionObject2D] will not be reported to collided with [CollisionObject2D]s.
Sets the [code]one_way_collision_margin[/code] of the shape owner identified by given [code]owner_id[/code] to [code]margin[/code] pixels.
Sets the [Transform2D] of the given shape owner.
The physics layers this CollisionObject2D is in. Collision objects can exist in one or more of 32 different layers. See also [member collision_mask].
[b]Note:[/b] A contact is detected if object A is in any of the layers that object B scans, or object B is in any layers that object A scans. See [url=https://docs.godotengine.org/en/latest/tutorials/physics/physics_introduction.html#collision-layers-and-masks]Collision layers and masks[/url] in the documentation for more information.
The physics layers this CollisionObject2D scans. Collision objects can scan one or more of 32 different layers. See also [member collision_layer].
[b]Note:[/b] A contact is detected if object A is in any of the layers that object B scans, or object B is in any layers that object A scans. See [url=https://docs.godotengine.org/en/latest/tutorials/physics/physics_introduction.html#collision-layers-and-masks]Collision layers and masks[/url] in the documentation for more information.
If [code]true[/code], 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 [code]collision_layer[/code] bit to be set.
Emitted when an input event occurs. Requires [member input_pickable] to be [code]true[/code] and at least one [code]collision_layer[/code] bit to be set. See [method _input_event] for details.
Emitted when the mouse pointer enters any of this object's shapes. Requires [member input_pickable] to be [code]true[/code] and at least one [code]collision_layer[/code] bit to be set.
Emitted when the mouse pointer exits all this object's shapes. Requires [member input_pickable] to be [code]true[/code] and at least one [code]collision_layer[/code] bit to be set.