2022-07-19 02:34:14 +08:00
<?xml version="1.0" encoding="UTF-8" ?>
2023-07-06 16:08:05 +08:00
<class name= "ShapeCast3D" inherits= "Node3D" xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation= "../class.xsd" >
2022-07-19 02:34:14 +08:00
<brief_description >
2023-04-29 04:59:03 +08:00
A 3D shape that sweeps a region of space to detect [CollisionObject3D]s.
2022-07-19 02:34:14 +08:00
</brief_description>
<description >
2023-04-29 04:59:03 +08:00
Shape casting allows to detect collision objects by sweeping its [member shape] along the cast direction determined by [member target_position]. This is similar to [RayCast3D], but it allows for sweeping a region of space, rather than just a straight line. [ShapeCast3D] can detect multiple collision objects. It is useful for things like wide laser beams or snapping a simple shape to a floor.
Immediate collision overlaps can be done with the [member target_position] set to [code]Vector3(0, 0, 0)[/code] and by calling [method force_shapecast_update] within the same physics frame. This helps to overcome some limitations of [Area3D] when used as an instantaneous detection area, as collision information isn't immediately available to it.
[b]Note:[/b] Shape casting is more computationally expensive than ray casting.
2022-07-19 02:34:14 +08:00
</description>
<tutorials >
</tutorials>
<methods >
<method name= "add_exception" >
<return type= "void" />
2023-02-24 06:45:16 +08:00
<param index= "0" name= "node" type= "CollisionObject3D" />
2022-07-19 02:34:14 +08:00
<description >
Adds a collision exception so the shape does not report collisions with the specified [CollisionObject3D] node.
</description>
</method>
<method name= "add_exception_rid" >
<return type= "void" />
2022-08-07 02:11:48 +08:00
<param index= "0" name= "rid" type= "RID" />
2022-07-19 02:34:14 +08:00
<description >
Adds a collision exception so the shape does not report collisions with the specified [RID].
</description>
</method>
<method name= "clear_exceptions" >
<return type= "void" />
<description >
2022-07-30 02:10:25 +08:00
Removes all collision exceptions for this [ShapeCast3D].
2022-07-19 02:34:14 +08:00
</description>
</method>
<method name= "force_shapecast_update" >
<return type= "void" />
<description >
2023-11-07 16:49:51 +08:00
Updates the collision information for the shape immediately, without waiting for the next [code]_physics_process[/code] call. Use this method, for example, when the shape or its parent has changed state.
2022-07-19 02:34:14 +08:00
[b]Note:[/b] [code]enabled == true[/code] is not required for this to work.
</description>
</method>
<method name= "get_closest_collision_safe_fraction" qualifiers= "const" >
<return type= "float" />
<description >
2022-07-30 02:10:25 +08:00
The fraction from the [ShapeCast3D]'s origin to its [member target_position] (between 0 and 1) of how far the shape can move without triggering a collision.
2022-07-19 02:34:14 +08:00
</description>
</method>
<method name= "get_closest_collision_unsafe_fraction" qualifiers= "const" >
<return type= "float" />
<description >
2022-07-30 02:10:25 +08:00
The fraction from the [ShapeCast3D]'s origin to its [member target_position] (between 0 and 1) of how far the shape must move to trigger a collision.
2022-07-19 02:34:14 +08:00
</description>
</method>
<method name= "get_collider" qualifiers= "const" >
<return type= "Object" />
2022-08-07 02:11:48 +08:00
<param index= "0" name= "index" type= "int" />
2022-07-19 02:34:14 +08:00
<description >
2022-08-10 10:00:19 +08:00
Returns the collided [Object] of one of the multiple collisions at [param index], or [code]null[/code] if no object is intersecting the shape (i.e. [method is_colliding] returns [code]false[/code]).
2022-07-19 02:34:14 +08:00
</description>
</method>
2022-11-02 04:17:18 +08:00
<method name= "get_collider_rid" qualifiers= "const" >
<return type= "RID" />
<param index= "0" name= "index" type= "int" />
<description >
Returns the [RID] of the collided object of one of the multiple collisions at [param index].
</description>
</method>
2022-07-19 02:34:14 +08:00
<method name= "get_collider_shape" qualifiers= "const" >
<return type= "int" />
2022-08-07 02:11:48 +08:00
<param index= "0" name= "index" type= "int" />
2022-07-19 02:34:14 +08:00
<description >
2022-08-10 10:00:19 +08:00
Returns the shape ID of the colliding shape of one of the multiple collisions at [param index], or [code]0[/code] if no object is intersecting the shape (i.e. [method is_colliding] returns [code]false[/code]).
2022-07-19 02:34:14 +08:00
</description>
</method>
<method name= "get_collision_count" qualifiers= "const" >
<return type= "int" />
<description >
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.
</description>
</method>
<method name= "get_collision_mask_value" qualifiers= "const" >
<return type= "bool" />
2022-08-07 02:11:48 +08:00
<param index= "0" name= "layer_number" type= "int" />
2022-07-19 02:34:14 +08:00
<description >
2022-08-10 10:00:19 +08:00
Returns whether or not the specified layer of the [member collision_mask] is enabled, given a [param layer_number] between 1 and 32.
2022-07-19 02:34:14 +08:00
</description>
</method>
<method name= "get_collision_normal" qualifiers= "const" >
<return type= "Vector3" />
2022-08-07 02:11:48 +08:00
<param index= "0" name= "index" type= "int" />
2022-07-19 02:34:14 +08:00
<description >
2022-08-10 10:00:19 +08:00
Returns the normal of one of the multiple collisions at [param index] of the intersecting object.
2022-07-19 02:34:14 +08:00
</description>
</method>
<method name= "get_collision_point" qualifiers= "const" >
<return type= "Vector3" />
2022-08-07 02:11:48 +08:00
<param index= "0" name= "index" type= "int" />
2022-07-19 02:34:14 +08:00
<description >
2022-08-10 10:00:19 +08:00
Returns the collision point of one of the multiple collisions at [param index] where the shape intersects the colliding object.
2022-07-19 02:34:14 +08:00
[b]Note:[/b] this point is in the [b]global[/b] coordinate system.
</description>
</method>
<method name= "is_colliding" qualifiers= "const" >
<return type= "bool" />
<description >
Returns whether any object is intersecting with the shape's vector (considering the vector length).
</description>
</method>
<method name= "remove_exception" >
<return type= "void" />
2023-02-24 06:45:16 +08:00
<param index= "0" name= "node" type= "CollisionObject3D" />
2022-07-19 02:34:14 +08:00
<description >
Removes a collision exception so the shape does report collisions with the specified [CollisionObject3D] node.
</description>
</method>
<method name= "remove_exception_rid" >
<return type= "void" />
2022-08-07 02:11:48 +08:00
<param index= "0" name= "rid" type= "RID" />
2022-07-19 02:34:14 +08:00
<description >
Removes a collision exception so the shape does report collisions with the specified [RID].
</description>
</method>
2023-07-04 03:29:37 +08:00
<method name= "resource_changed" is_deprecated= "true" >
2022-07-19 02:34:14 +08:00
<return type= "void" />
2022-08-07 02:11:48 +08:00
<param index= "0" name= "resource" type= "Resource" />
2022-07-19 02:34:14 +08:00
<description >
2023-07-04 03:29:37 +08:00
[i]Obsoleted.[/i] Use [signal Resource.changed] instead.
2022-07-19 02:34:14 +08:00
</description>
</method>
<method name= "set_collision_mask_value" >
<return type= "void" />
2022-08-07 02:11:48 +08:00
<param index= "0" name= "layer_number" type= "int" />
<param index= "1" name= "value" type= "bool" />
2022-07-19 02:34:14 +08:00
<description >
2022-08-10 10:00:19 +08:00
Based on [param value], enables or disables the specified layer in the [member collision_mask], given a [param layer_number] between 1 and 32.
2022-07-19 02:34:14 +08:00
</description>
</method>
</methods>
<members >
<member name= "collide_with_areas" type= "bool" setter= "set_collide_with_areas" getter= "is_collide_with_areas_enabled" default= "false" >
2023-11-07 16:49:51 +08:00
If [code]true[/code], collisions with [Area3D]s will be reported.
2022-07-19 02:34:14 +08:00
</member>
<member name= "collide_with_bodies" type= "bool" setter= "set_collide_with_bodies" getter= "is_collide_with_bodies_enabled" default= "true" >
2023-11-07 16:49:51 +08:00
If [code]true[/code], collisions with [PhysicsBody3D]s will be reported.
2022-07-19 02:34:14 +08:00
</member>
<member name= "collision_mask" type= "int" setter= "set_collision_mask" getter= "get_collision_mask" default= "1" >
2022-07-30 02:10:25 +08:00
The shape's collision mask. Only objects in at least one collision layer enabled in the mask will be detected. See [url=$DOCS_URL/tutorials/physics/physics_introduction.html#collision-layers-and-masks]Collision layers and masks[/url] in the documentation for more information.
2022-07-19 02:34:14 +08:00
</member>
<member name= "collision_result" type= "Array" setter= "" getter= "_get_collision_result" default= "[]" >
2022-07-30 02:10:25 +08:00
Returns the complete collision information from the collision sweep. The data returned is the same as in the [method PhysicsDirectSpaceState3D.get_rest_info] method.
2022-07-19 02:34:14 +08:00
</member>
<member name= "debug_shape_custom_color" type= "Color" setter= "set_debug_shape_custom_color" getter= "get_debug_shape_custom_color" default= "Color(0, 0, 0, 1)" >
The custom color to use to draw the shape in the editor and at run-time if [b]Visible Collision Shapes[/b] is enabled in the [b]Debug[/b] menu. This color will be highlighted at run-time if the [ShapeCast3D] is colliding with something.
If set to [code]Color(0.0, 0.0, 0.0)[/code] (by default), the color set in [member ProjectSettings.debug/shapes/collision/shape_color] is used.
</member>
<member name= "enabled" type= "bool" setter= "set_enabled" getter= "is_enabled" default= "true" >
If [code]true[/code], collisions will be reported.
</member>
<member name= "exclude_parent" type= "bool" setter= "set_exclude_parent_body" getter= "get_exclude_parent_body" default= "true" >
If [code]true[/code], the parent node will be excluded from collision detection.
</member>
<member name= "margin" type= "float" setter= "set_margin" getter= "get_margin" default= "0.0" >
The collision margin for the shape. A larger margin helps detecting collisions more consistently, at the cost of precision.
</member>
<member name= "max_results" type= "int" setter= "set_max_results" getter= "get_max_results" default= "32" >
The number of intersections can be limited with this parameter, to reduce the processing time.
</member>
<member name= "shape" type= "Shape3D" setter= "set_shape" getter= "get_shape" >
2022-07-30 02:10:25 +08:00
The [Shape3D]-derived shape to be used for collision queries.
2022-07-19 02:34:14 +08:00
</member>
<member name= "target_position" type= "Vector3" setter= "set_target_position" getter= "get_target_position" default= "Vector3(0, -1, 0)" >
The shape's destination point, relative to this node's [code]position[/code].
</member>
</members>
</class>