Debian Codegraph @

doc/classes/RayCast3D.xml

raw symbols SCIP
1 <?xml version="1.0" encoding="UTF-8" ?>
2 <class name="RayCast3D" inherits="Node3D" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
3 <brief_description>
4 A ray in 3D space, used to find the first collision object it intersects.
5 </brief_description>
6 <description>
7 A raycast represents a ray from its origin to its [member target_position] that finds the closest object along its path, if it intersects any.
8 [RayCast3D] can ignore some objects by adding them to an exception list, by making its detection reporting ignore [Area3D]s ([member collide_with_areas]) or [PhysicsBody3D]s ([member collide_with_bodies]), or by configuring physics layers.
9 [RayCast3D] calculates intersection every physics frame, and it holds the result until the next physics frame. For an immediate raycast, or if you want to configure a [RayCast3D] multiple times within the same physics frame, use [method force_raycast_update].
10 To sweep over a region of 3D space, you can approximate the region with multiple [RayCast3D]s or use [ShapeCast3D].
11 </description>
12 <tutorials>
13 <link title="Ray-casting">$DOCS_URL/tutorials/physics/ray-casting.html</link>
14 <link title="3D Voxel Demo">https://godotengine.org/asset-library/asset/2755</link>
15 </tutorials>
16 <methods>
17 <method name="add_exception">
18 <return type="void" />
19 <param index="0" name="node" type="CollisionObject3D" />
20 <description>
21 Adds a collision exception so the ray does not report collisions with the specified [param node].
22 </description>
23 </method>
24 <method name="add_exception_rid">
25 <return type="void" />
26 <param index="0" name="rid" type="RID" />
27 <description>
28 Adds a collision exception so the ray does not report collisions with the specified [RID].
29 </description>
30 </method>
31 <method name="clear_exceptions">
32 <return type="void" />
33 <description>
34 Removes all collision exceptions for this ray.
35 </description>
36 </method>
37 <method name="force_raycast_update">
38 <return type="void" />
39 <description>
40 Updates the collision information for the ray immediately, without waiting for the next [code]_physics_process[/code] call. Use this method, for example, when the ray or its parent has changed state.
41 [b]Note:[/b] [member enabled] does not need to be [code]true[/code] for this to work.
42 </description>
43 </method>
44 <method name="get_collider" qualifiers="const">
45 <return type="Object" />
46 <description>
47 Returns the first object that the ray intersects, or [code]null[/code] if no object is intersecting the ray (i.e. [method is_colliding] returns [code]false[/code]).
48 [b]Note:[/b] This object is not guaranteed to be a [CollisionObject3D]. For example, if the ray intersects a [CSGShape3D] or a [GridMap], the method will return a [CSGShape3D] or [GridMap] instance.
49 </description>
50 </method>
51 <method name="get_collider_rid" qualifiers="const">
52 <return type="RID" />
53 <description>
54 Returns the [RID] of the first object that the ray intersects, or an empty [RID] if no object is intersecting the ray (i.e. [method is_colliding] returns [code]false[/code]).
55 </description>
56 </method>
57 <method name="get_collider_shape" qualifiers="const">
58 <return type="int" />
59 <description>
60 Returns the shape ID of the first object that the ray intersects, or [code]0[/code] if no object is intersecting the ray (i.e. [method is_colliding] returns [code]false[/code]).
61 To get the intersected shape node, for a [CollisionObject3D] target, use:
62 [codeblocks]
63 [gdscript]
64 var target = get_collider() # A CollisionObject3D.
65 var shape_id = get_collider_shape() # The shape index in the collider.
66 var owner_id = target.shape_find_owner(shape_id) # The owner ID in the collider.
67 var shape = target.shape_owner_get_owner(owner_id)
68 [/gdscript]
69 [csharp]
70 var target = (CollisionObject3D)GetCollider(); // A CollisionObject3D.
71 var shapeId = GetColliderShape(); // The shape index in the collider.
72 var ownerId = target.ShapeFindOwner(shapeId); // The owner ID in the collider.
73 var shape = target.ShapeOwnerGetOwner(ownerId);
74 [/csharp]
75 [/codeblocks]
76 </description>
77 </method>
78 <method name="get_collision_face_index" qualifiers="const">
79 <return type="int" />
80 <description>
81 Returns the collision object's face index at the collision point, or [code]-1[/code] if the shape intersecting the ray is not a [ConcavePolygonShape3D].
82 </description>
83 </method>
84 <method name="get_collision_mask_value" qualifiers="const">
85 <return type="bool" />
86 <param index="0" name="layer_number" type="int" />
87 <description>
88 Returns whether or not the specified layer of the [member collision_mask] is enabled, given a [param layer_number] between 1 and 32.
89 </description>
90 </method>
91 <method name="get_collision_normal" qualifiers="const">
92 <return type="Vector3" />
93 <description>
94 Returns the normal of the intersecting object's shape at the collision point, or [code]Vector3(0, 0, 0)[/code] if the ray starts inside the shape and [member hit_from_inside] is [code]true[/code].
95 [b]Note:[/b] Check that [method is_colliding] returns [code]true[/code] before calling this method to ensure the returned normal is valid and up-to-date.
96 </description>
97 </method>
98 <method name="get_collision_point" qualifiers="const">
99 <return type="Vector3" />
100 <description>
101 Returns the collision point at which the ray intersects the closest object, in the global coordinate system. If [member hit_from_inside] is [code]true[/code] and the ray starts inside of a collision shape, this function will return the origin point of the ray.
102 [b]Note:[/b] Check that [method is_colliding] returns [code]true[/code] before calling this method to ensure the returned point is valid and up-to-date.
103 </description>
104 </method>
105 <method name="is_colliding" qualifiers="const">
106 <return type="bool" />
107 <description>
108 Returns whether any object is intersecting with the ray's vector (considering the vector length).
109 </description>
110 </method>
111 <method name="remove_exception">
112 <return type="void" />
113 <param index="0" name="node" type="CollisionObject3D" />
114 <description>
115 Removes a collision exception so the ray can report collisions with the specified [param node].
116 </description>
117 </method>
118 <method name="remove_exception_rid">
119 <return type="void" />
120 <param index="0" name="rid" type="RID" />
121 <description>
122 Removes a collision exception so the ray can report collisions with the specified [RID].
123 </description>
124 </method>
125 <method name="set_collision_mask_value">
126 <return type="void" />
127 <param index="0" name="layer_number" type="int" />
128 <param index="1" name="value" type="bool" />
129 <description>
130 Based on [param value], enables or disables the specified layer in the [member collision_mask], given a [param layer_number] between 1 and 32.
131 </description>
132 </method>
133 </methods>
134 <members>
135 <member name="collide_with_areas" type="bool" setter="set_collide_with_areas" getter="is_collide_with_areas_enabled" default="false">
136 If [code]true[/code], collisions with [Area3D]s will be reported.
137 </member>
138 <member name="collide_with_bodies" type="bool" setter="set_collide_with_bodies" getter="is_collide_with_bodies_enabled" default="true">
139 If [code]true[/code], collisions with [PhysicsBody3D]s will be reported.
140 </member>
141 <member name="collision_mask" type="int" setter="set_collision_mask" getter="get_collision_mask" default="1">
142 The ray'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.
143 </member>
144 <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)">
145 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 [RayCast3D] is colliding with something.
146 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.
147 </member>
148 <member name="debug_shape_thickness" type="int" setter="set_debug_shape_thickness" getter="get_debug_shape_thickness" default="2">
149 If set to [code]1[/code], a line is used as the debug shape. Otherwise, a truncated pyramid is drawn to represent the [RayCast3D]. Requires [b]Visible Collision Shapes[/b] to be enabled in the [b]Debug[/b] menu for the debug shape to be visible at run-time.
150 </member>
151 <member name="enabled" type="bool" setter="set_enabled" getter="is_enabled" default="true">
152 If [code]true[/code], collisions will be reported.
153 </member>
154 <member name="exclude_parent" type="bool" setter="set_exclude_parent_body" getter="get_exclude_parent_body" default="true">
155 If [code]true[/code], this raycast will not report collisions with its parent node. This property only has an effect if the parent node is a [CollisionObject3D]. See also [method Node.get_parent] and [method add_exception].
156 </member>
157 <member name="hit_back_faces" type="bool" setter="set_hit_back_faces" getter="is_hit_back_faces_enabled" default="true">
158 If [code]true[/code], the ray will hit back faces with concave polygon shapes with back face enabled or heightmap shapes.
159 </member>
160 <member name="hit_from_inside" type="bool" setter="set_hit_from_inside" getter="is_hit_from_inside_enabled" default="false">
161 If [code]true[/code], the ray will detect a hit when starting inside shapes. In this case the collision normal will be [code]Vector3(0, 0, 0)[/code]. Does not affect shapes with no volume like concave polygon or heightmap.
162 </member>
163 <member name="target_position" type="Vector3" setter="set_target_position" getter="get_target_position" default="Vector3(0, -1, 0)">
164 The ray's destination point, relative to this raycast's [member Node3D.position].
165 </member>
166 </members>
167 </class>