Update the raycasts at a faster rate than physics

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

Is there a way to increase the rate of raycasts updating? I keep having an issue where my collision is happening but it’s either too late or too soon. It’s making things look super weird because I want an “obstacle” to stop moving as soon as the raycast(s) have hit something. Sometimes they float above another object, or they go a little too far in and they clip through.

Edit: I’ve used _process() but obviously relying on frame rate is not reliable.

:bust_in_silhouette: Reply From: Lopy

You can change update rate in the project settings, under Physics/Common/Physics FPS.

Collisions should be checked inside _physics_process() instead of _process().
If your obstacles stop moving a bit too late, or early, you can try to have them move to their position on the last tic, or stop only on the next one.
Finally, maybe you would have better luck using Areas instead?

I tried increasing the physics update but that messes up some other physics related things (will prob try again and just adjust for the new rate). I did try using area and had the same issue of it updating too late or too early.

Do areas update quicker than raycasts or at the physics rate as well?

profjle | 2020-12-23 04:04