intersect_ray inconsistent / detect fast-moving collisions another way?
Asked Answered
S

1

0

Godot 3.5.1.stable

I have a very fast moving point (hundreds of units / sec), currently implemented as a Spatial that advances its position each physics frame.
I would like to detect any colliders it passes through, and given its speed, it may pass right through one or multiple in a single physics frame.
I decided to try and implement this using PhysicsDirectSpaceState.intersect_ray(), casting from the previous position to the new position, then from the position of collision to the new position, etc, until there are no more colliders to be found between the old and new position.
Unfortunately this does not behave quite right when the previous physics update places the raycast start position within 0.01 units of a collider.
Using Bullet, casting from that distance does not detect the collider, and using GodotPhysics it does detect the collider, but it also detects the collider when casting from exactly on its surface, which is how I had intended to advance the ray.
I can see quite a few workarounds here involving adjusting various positions by slight margins, but given the inconsistencies between physics engines I imagine many would simply be misuses of unreliable behaviours, since I don't know how intersect_ray is supposed to behave/be used.
Maybe I am even taking completely the wrong approach and there is a better way do to this?

edit; I realize I was a tad unclear when I wrote this, I don't just want to know what colliders it passes through but I do actually want the collision position on the surface of the collider too.

Stubbs answered 13/2, 2023 at 22:7 Comment(0)
S
0

Stubbs
For lack of a better idea, I investigated continuous collision detection on a RigidBody, but it doesn't really help because I don't want collision response. It also means I need to supply a collision shape even though I don't need any volume.

Stubbs answered 15/2, 2023 at 20:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.