
Lately I finished the "Designing Games", by Tynan Sylvester, lead developer of Rimworld. Highly recommend to everyone who is interested in game design. This book is not about the code, but about experience that your game will create.
TL;DR
Don’t rely on colliders for fast-moving objects. Use Physics.Raycast
to detect collisions reliably.
The Full Story
Let’s talk about how to actually handle this.
This problem usually shows up with bullets or similar high-speed objects—think arrows or anything else zipping across the screen. In most other cases, you can just set the Rigidbody's Collision Detection to Continuous, and that should be enough.
The root of the issue lies in how collision detection works. It follows a lifecycle and doesn’t check for collisions every single frame. So if your GameObject
is moving fast enough, it might slip right through another collider between those checks—essentially sneaking past without ever triggering a collision.
To fix this, you'll need a custom collision check. Your specific implementation may vary, but here’s a general approach that works:
FixedUpdate
for performance reasons), raycast again in case the target is moving.FixedUpdate
, compare the current position of the object with that stored hit point.With this method, it doesn’t matter how fast your "bullet" moves—it won't skip over anything important.
You might also be interested in the following posts:
Lately I finished the "Designing Games", by Tynan Sylvester, lead developer of Rimworld. Highly recommend to everyone who is interested in game design. This book is not about the code, but about experience that your game will create.