File tree Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -151,7 +151,24 @@ data:
151151 metadata: Variant() # metadata of collider
152152 }
153153
154- The data is similar in 3D space, using Vector3 coordinates.
154+ The data is similar in 3D space, using Vector3 coordinates. Note that to enable collisions
155+ with Area3D, the boolean parameter ``collide_with_areas `` must be set to ``true ``.
156+
157+ .. tabs ::
158+ .. code-tab :: gdscript GDScript
159+ const RAY_LENGTH = 1000
160+
161+ func _physics_process(delta):
162+ var space_state = get_world_3d().direct_space_state
163+ var cam = $Camera3D
164+ var mousepos = get_viewport().get_mouse_position()
165+
166+ var origin = cam.project_ray_origin(mousepos)
167+ var end = origin + cam.project_ray_normal(mousepos) * RAY_LENGTH
168+ var query = PhysicsRayQueryParameters3D.create(origin, end)
169+ query.collide_with_areas = true
170+
171+ var result = space_state.intersect_ray(query)
155172
156173Collision exceptions
157174--------------------
@@ -278,6 +295,5 @@ To obtain it using a camera, the following code can be used:
278295 }
279296 }
280297
281-
282298Remember that during ``_input() ``, the space may be locked, so in practice
283299this query should be run in ``_physics_process() ``.
You can’t perform that action at this time.
0 commit comments