2017-09-12 20:42:36 +00:00
<?xml version="1.0" encoding="UTF-8" ?>
2022-03-16 22:01:02 +00:00
<class name= "CollisionObject2D" inherits= "Node2D" version= "3.5" xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation= "../class.xsd" >
2017-09-12 20:42:36 +00:00
<brief_description >
2017-09-24 02:47:13 +00:00
Base node for 2D collision objects.
2017-09-12 20:42:36 +00:00
</brief_description>
<description >
2017-10-21 10:33:50 +00:00
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.
2017-09-12 20:42:36 +00:00
</description>
<tutorials >
</tutorials>
<methods >
<method name= "_input_event" qualifiers= "virtual" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
<argument index= "0" name= "viewport" type= "Object" />
<argument index= "1" name= "event" type= "InputEvent" />
<argument index= "2" name= "shape_idx" type= "int" />
2017-09-12 20:42:36 +00:00
<description >
2019-07-21 07:57:36 +00:00
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.
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "create_shape_owner" >
2021-07-30 13:28:05 +00:00
<return type= "int" />
<argument index= "0" name= "owner" type= "Object" />
2017-09-12 20:42:36 +00:00
<description >
2017-09-24 02:47:13 +00:00
Creates a new shape owner for the given object. Returns [code]owner_id[/code] of the new owner for future reference.
2017-09-12 20:42:36 +00:00
</description>
</method>
2020-10-13 12:17:00 +00:00
<method name= "get_collision_layer_bit" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "bool" />
<argument index= "0" name= "bit" type= "int" />
2020-10-13 12:17:00 +00:00
<description >
Returns whether or not the specified [code]bit[/code] of the [member collision_layer] is set.
</description>
</method>
<method name= "get_collision_mask_bit" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "bool" />
<argument index= "0" name= "bit" type= "int" />
2020-10-13 12:17:00 +00:00
<description >
Returns whether or not the specified [code]bit[/code] of the [member collision_mask] is set.
</description>
</method>
2017-09-12 20:42:36 +00:00
<method name= "get_rid" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "RID" />
2017-09-12 20:42:36 +00:00
<description >
2017-09-24 02:47:13 +00:00
Returns the object's [RID].
2017-09-12 20:42:36 +00:00
</description>
</method>
2019-01-26 21:21:53 +00:00
<method name= "get_shape_owner_one_way_collision_margin" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "float" />
<argument index= "0" name= "owner_id" type= "int" />
2019-01-26 21:21:53 +00:00
<description >
2020-01-13 22:08:42 +00:00
Returns the [code]one_way_collision_margin[/code] of the shape owner identified by given [code]owner_id[/code].
2019-01-26 21:21:53 +00:00
</description>
</method>
2017-09-12 20:42:36 +00:00
<method name= "get_shape_owners" >
2021-07-30 13:28:05 +00:00
<return type= "Array" />
2017-09-12 20:42:36 +00:00
<description >
2017-09-24 02:47:13 +00:00
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.
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "is_shape_owner_disabled" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "bool" />
<argument index= "0" name= "owner_id" type= "int" />
2017-09-12 20:42:36 +00:00
<description >
2018-12-20 12:46:54 +00:00
If [code]true[/code], the shape owner and its shapes are disabled.
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "is_shape_owner_one_way_collision_enabled" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "bool" />
<argument index= "0" name= "owner_id" type= "int" />
2017-09-12 20:42:36 +00:00
<description >
2019-03-29 22:37:35 +00:00
Returns [code]true[/code] if collisions for the shape owner originating from this [CollisionObject2D] will not be reported to collided with [CollisionObject2D]s.
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "remove_shape_owner" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
<argument index= "0" name= "owner_id" type= "int" />
2017-09-12 20:42:36 +00:00
<description >
2017-09-24 02:47:13 +00:00
Removes the given shape owner.
2017-09-12 20:42:36 +00:00
</description>
</method>
2020-10-13 12:17:00 +00:00
<method name= "set_collision_layer_bit" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
<argument index= "0" name= "bit" type= "int" />
<argument index= "1" name= "value" type= "bool" />
2020-10-13 12:17:00 +00:00
<description >
2021-07-24 20:55:11 +00:00
If [code]value[/code] is [code]true[/code], sets the specified [code]bit[/code] in the the [member collision_layer].
If [code]value[/code] is [code]false[/code], clears the specified [code]bit[/code] in the the [member collision_layer].
2020-10-13 12:17:00 +00:00
</description>
</method>
<method name= "set_collision_mask_bit" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
<argument index= "0" name= "bit" type= "int" />
<argument index= "1" name= "value" type= "bool" />
2020-10-13 12:17:00 +00:00
<description >
2021-07-24 20:55:11 +00:00
If [code]value[/code] is [code]true[/code], sets the specified [code]bit[/code] in the the [member collision_mask].
If [code]value[/code] is [code]false[/code], clears the specified [code]bit[/code] in the the [member collision_mask].
2020-10-13 12:17:00 +00:00
</description>
</method>
2017-09-12 20:42:36 +00:00
<method name= "shape_find_owner" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "int" />
<argument index= "0" name= "shape_index" type= "int" />
2017-09-12 20:42:36 +00:00
<description >
2017-09-24 02:47:13 +00:00
Returns the [code]owner_id[/code] of the given shape.
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "shape_owner_add_shape" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
<argument index= "0" name= "owner_id" type= "int" />
<argument index= "1" name= "shape" type= "Shape2D" />
2017-09-12 20:42:36 +00:00
<description >
2017-09-24 02:47:13 +00:00
Adds a [Shape2D] to the shape owner.
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "shape_owner_clear_shapes" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
<argument index= "0" name= "owner_id" type= "int" />
2017-09-12 20:42:36 +00:00
<description >
2017-09-24 02:47:13 +00:00
Removes all shapes from the shape owner.
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "shape_owner_get_owner" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "Object" />
<argument index= "0" name= "owner_id" type= "int" />
2017-09-12 20:42:36 +00:00
<description >
2017-09-24 02:47:13 +00:00
Returns the parent object of the given shape owner.
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "shape_owner_get_shape" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "Shape2D" />
<argument index= "0" name= "owner_id" type= "int" />
<argument index= "1" name= "shape_id" type= "int" />
2017-09-12 20:42:36 +00:00
<description >
2017-09-24 02:47:13 +00:00
Returns the [Shape2D] with the given id from the given shape owner.
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "shape_owner_get_shape_count" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "int" />
<argument index= "0" name= "owner_id" type= "int" />
2017-09-12 20:42:36 +00:00
<description >
2017-09-24 02:47:13 +00:00
Returns the number of shapes the given shape owner contains.
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "shape_owner_get_shape_index" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "int" />
<argument index= "0" name= "owner_id" type= "int" />
<argument index= "1" name= "shape_id" type= "int" />
2017-09-12 20:42:36 +00:00
<description >
2017-12-07 19:17:08 +00:00
Returns the child index of the [Shape2D] with the given id from the given shape owner.
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "shape_owner_get_transform" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "Transform2D" />
<argument index= "0" name= "owner_id" type= "int" />
2017-09-12 20:42:36 +00:00
<description >
2017-09-24 02:47:13 +00:00
Returns the shape owner's [Transform2D].
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "shape_owner_remove_shape" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
<argument index= "0" name= "owner_id" type= "int" />
<argument index= "1" name= "shape_id" type= "int" />
2017-09-12 20:42:36 +00:00
<description >
2017-09-24 02:47:13 +00:00
Removes a shape from the given shape owner.
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "shape_owner_set_disabled" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
<argument index= "0" name= "owner_id" type= "int" />
<argument index= "1" name= "disabled" type= "bool" />
2017-09-12 20:42:36 +00:00
<description >
2018-12-20 12:46:54 +00:00
If [code]true[/code], disables the given shape owner.
2017-09-12 20:42:36 +00:00
</description>
</method>
<method name= "shape_owner_set_one_way_collision" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
<argument index= "0" name= "owner_id" type= "int" />
<argument index= "1" name= "enable" type= "bool" />
2017-09-12 20:42:36 +00:00
<description >
2019-03-29 22:37:35 +00:00
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.
2017-09-12 20:42:36 +00:00
</description>
</method>
2019-01-26 21:21:53 +00:00
<method name= "shape_owner_set_one_way_collision_margin" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
<argument index= "0" name= "owner_id" type= "int" />
<argument index= "1" name= "margin" type= "float" />
2019-01-26 21:21:53 +00:00
<description >
2020-01-13 22:08:42 +00:00
Sets the [code]one_way_collision_margin[/code] of the shape owner identified by given [code]owner_id[/code] to [code]margin[/code] pixels.
2019-01-26 21:21:53 +00:00
</description>
</method>
2017-09-12 20:42:36 +00:00
<method name= "shape_owner_set_transform" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
<argument index= "0" name= "owner_id" type= "int" />
<argument index= "1" name= "transform" type= "Transform2D" />
2017-09-12 20:42:36 +00:00
<description >
2017-09-24 02:47:13 +00:00
Sets the [Transform2D] of the given shape owner.
2017-09-12 20:42:36 +00:00
</description>
</method>
</methods>
<members >
2020-10-13 12:17:00 +00:00
<member name= "collision_layer" type= "int" setter= "set_collision_layer" getter= "get_collision_layer" default= "1" >
The physics layers this CollisionObject2D is in. Collision objects can exist in one or more of 32 different layers. See also [member collision_mask].
2021-11-15 16:11:20 +00:00
[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=$DOCS_URL/tutorials/physics/physics_introduction.html#collision-layers-and-masks]Collision layers and masks[/url] in the documentation for more information.
2020-10-13 12:17:00 +00:00
</member>
<member name= "collision_mask" type= "int" setter= "set_collision_mask" getter= "get_collision_mask" default= "1" >
The physics layers this CollisionObject2D scans. Collision objects can scan one or more of 32 different layers. See also [member collision_layer].
2021-11-15 16:11:20 +00:00
[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=$DOCS_URL/tutorials/physics/physics_introduction.html#collision-layers-and-masks]Collision layers and masks[/url] in the documentation for more information.
2020-10-13 12:17:00 +00:00
</member>
2020-07-15 10:56:16 +00:00
<member name= "input_pickable" type= "bool" setter= "set_pickable" getter= "is_pickable" default= "true" >
2022-01-18 00:04:43 +00:00
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 [member collision_layer] bit to be set.
2017-09-12 20:42:36 +00:00
</member>
</members>
<signals >
<signal name= "input_event" >
2021-07-30 13:28:05 +00:00
<argument index= "0" name= "viewport" type= "Node" />
<argument index= "1" name= "event" type= "InputEvent" />
<argument index= "2" name= "shape_idx" type= "int" />
2017-09-12 20:42:36 +00:00
<description >
2020-07-27 20:46:04 +00:00
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.
2017-09-12 20:42:36 +00:00
</description>
</signal>
<signal name= "mouse_entered" >
<description >
2020-07-27 20:46:04 +00:00
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.
2017-09-12 20:42:36 +00:00
</description>
</signal>
<signal name= "mouse_exited" >
<description >
2020-07-27 20:46:04 +00:00
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.
2017-09-12 20:42:36 +00:00
</description>
</signal>
</signals>
<constants >
</constants>
</class>