Sensors as bullets

While raycast seems to imply infinite-velocity "hitscan" projectiles, you can just as easily use it for projectiles with finite (and even changing) velocity. On each simulation step, raycast from the projectile's current position to the next position based on that velocity (p + t * v). If the raycast hits something, treat that as a collision event and respond accordingly. Otherwise, move the projectile to the final position.
kdmiller3 wrote:
While raycast seems to imply infinite-velocity "hitscan" projectiles, you can just as easily use it for projectiles with finite (and even changing) velocity. On each simulation step, raycast from the projectile's current position to the next position based on that velocity (p + t * v). If the raycast hits something, treat that as a collision event and respond accordingly. Otherwise, move the projectile to the final position.


Xilliah, can you use kdmiller's technique? In my experience this is how games normally handle fast projectiles.

Original thread: https://box2d.org/forum/viewtopic.php?t=1697