Is it OK to do multiple 3D raycasts in only one frame?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By MomoVR

I’m trying to cast some rays a bunch of times using DirectSpaceState.intersect_ray(), here i get the hit point by doing hit["position"] where hit is the result of the raycast.
For some reason the hit points are not accurate and appear at seemingly random positions.
However if i put a delay in between by doing yield(get_tree(), "physics_frame")
This makes everything work, but it’s too slow now because it waits every frame.

How are the rays being sent out? Individually? In a for loop? Sharing some more of the code would shine a light on the problem.

Ertain | 2022-07-01 23:35

:bust_in_silhouette: Reply From: path9263

Call raycastNode.force_raycast_update( ) after moving your ray.