Node for physics collision sweep and immediate overlap queries. Similar to the [RayCast2D] node.
</brief_description>
<description>
Shape casting allows to detect collision objects by sweeping the [member shape] along the cast direction determined by [member target_position] (useful for things like beam weapons).
Immediate collision overlaps can be done with the [member target_position] set to [code]Vector2(0, 0)[/code] and by calling [method force_shapecast_update] within the same [b]physics_frame[/b]. This also helps to overcome some limitations of [Area2D] when used as a continuous detection area, often requiring waiting a couple of frames before collision information is available to [Area2D] nodes, and when using the signals creates unnecessary complexity.
The node can detect multiple collision objects, but it's usually used to detect the first collision.
[b]Note:[/b] Shape casting is more computationally expensive compared to ray casting.
</description>
<tutorials>
</tutorials>
<methods>
<methodname="add_exception">
<returntype="void"/>
<argumentindex="0"name="node"type="Object"/>
<description>
Adds a collision exception so the shape does not report collisions with the specified [CollisionObject2D] node.
</description>
</method>
<methodname="add_exception_rid">
<returntype="void"/>
<argumentindex="0"name="rid"type="RID"/>
<description>
Adds a collision exception so the shape does not report collisions with the specified [RID].
</description>
</method>
<methodname="clear_exceptions">
<returntype="void"/>
<description>
Removes all collision exceptions for this shape.
</description>
</method>
<methodname="force_shapecast_update">
<returntype="void"/>
<description>
Updates the collision information for the shape. Use this method to update the collision information immediately instead of waiting for the next [code]_physics_process[/code] call, for example if the shape or its parent has changed state.
[b]Note:[/b] [code]enabled[/code] is not required for this to work.
The fraction from the [ShapeCast2D]'s origin to its [member target_position] (between 0 and 1) of how far the shape can move without triggering a collision.
The fraction from the [ShapeCast2D]'s origin to its [member target_position] (between 0 and 1) of how far the shape must move to trigger a collision.
</description>
</method>
<methodname="get_collider"qualifiers="const">
<returntype="Object"/>
<argumentindex="0"name="index"type="int"/>
<description>
Returns the collided [Object] of one of the multiple collisions at [code]index[/code], or [code]null[/code] if no object is intersecting the shape (i.e. [method is_colliding] returns [code]false[/code]).
Returns the shape ID of the colliding shape of one of the multiple collisions at [code]index[/code], or [code]0[/code] if no object is intersecting the shape (i.e. [method is_colliding] returns [code]false[/code]).
The number of collisions detected at the point of impact. Use this to iterate over multiple collisions as provided by [method get_collider], [method get_collider_shape], [method get_collision_point], and [method get_collision_normal] methods.
Returns the collision point of one of the multiple collisions at [code]index[/code] where the shape intersects the colliding object.
[b]Note:[/b] this point is in the [b]global[/b] coordinate system.
</description>
</method>
<methodname="is_colliding"qualifiers="const">
<returntype="bool"/>
<description>
Returns whether any object is intersecting with the shape's vector (considering the vector length).
</description>
</method>
<methodname="remove_exception">
<returntype="void"/>
<argumentindex="0"name="node"type="Object"/>
<description>
Removes a collision exception so the shape does report collisions with the specified [CollisionObject2D] node.
</description>
</method>
<methodname="remove_exception_rid">
<returntype="void"/>
<argumentindex="0"name="rid"type="RID"/>
<description>
Removes a collision exception so the shape does report collisions with the specified [RID].
</description>
</method>
<methodname="set_collision_mask_value">
<returntype="void"/>
<argumentindex="0"name="layer_number"type="int"/>
<argumentindex="1"name="value"type="bool"/>
<description>
Based on [code]value[/code], enables or disables the specified layer in the [member collision_mask], given a [code]layer_number[/code] between 1 and 32.
Returns the complete collision information from the collision sweep. The data returned is the same as in the [method Physics2DDirectSpaceState.get_rest_info] method.