I could see why you might not want to fill under the terrain in a game that features things like underground caves, but thin terrain seems to be present in a huge majority of 3D games (even those without underground features) and is not engine-specific. Why is terrain almost always a fragile piece of origami that’s so easily punctured?
In: Technology
I’m going to chime in as a 2D game developer, although similar principles apply to 3D games.
Imagine a bullet traveling at 600m/s being shot at a 5m thick wall. Assuming 60fps, the bullet will travel 10m every tick. So it you are just checking for point collisions every tick, then the bullet will be on one side of the wall one tick, and on the other side the next tick, completely bypassing it.
What you need to do is, instead of checking for point collisions (∆x^2 + ∆y^2 < r^2 ), you need to check for line-to-circle, or line-to-line collisions.
These aren’t actually all that expensive, but the cost does add up. So the common sense approach is to do this for high velocity objects like railgun bullets or hitscan weapons, and use point collisions for most other things.
Consider a shotgun that shoots 200 pellets per shot. You want to minimize the number of calculations you have for each of those projectiles. But if it is a sniper rifle that shoots once per second, you can go all in, and do precise collision checks all you want.
Also, I mentioned hitscan weapons above. Those are actually great from a performance point of vjew, as you just calculate them once, instead of having to do it every tick. But for a regular high-speed projectile, you need to do calculations every tick. However, against static objects like terrain or props, you can still just do the whole calculation once, and note when the projectile will collide with terrain. Then, on every tick, you just need to check the projectile against the moving entities like players, enemies, etc to see if you hit anything before you hit the terrain.
I know this doesn’t directly answer the question, but I hope it provides some useful insight at least.
Latest Answers