As a side-project I’m making a small retro-FPS. So far, things are going fairly well, I think.
At the moment all collision-related matters are being handled by Panda’s built-in collision system.
But there is one thing that I’m yet troubled by: the question of how to handle collision for projectiles. Specifically, non-hitscan projectiles, of the sort that fly through the air, and that may potentially be avoided.
Now, the obvious way to implement such collision is to give each projectile a CollisionSphere. However, depending on the size and speed of the projectile and the frame-rate of the game, there’s a risk that projectiles might “skip over” an object.
I could activate the “respect previous transform” functionality (as described here).
However, the documentation indicates that this feature is only implemented for CollisionSpheres colliding into CollisionPolygons, which is fine for projectiles hitting walls, but not for projectiles hitting characters–those last currently use CollisionCapsules.
I’m also not sure of what the overhead of this system might be. I was preparing to experiment to determine whether or not it is too heavy when I discovered the “sphere-into-polygon” limitation mentioned above.
Another approach might be to model the projectiles as CollisionCapsules. This would make the projectile longer–and thus less likely to skip over things–without increasing its width or height.
However, if the capsule is of fixed length, then there’s the risk that collisions could happen “behind” the projectile, which might undermine the apparent fairness of projectile collisions. Conversely, if I update the capsule-length each frame then there’s additional overhead, and I don’t know whether it’s likely to perform well.
Finally, I could implement my projectiles as CollisionSegments. These would be treated much like the capsules, above, likely updated each frame. Again, I’m not sure of the overhead, although my instinct is that they should be cheaper than capsules.
Right now I’m not at all confident of which way to go here–hence this thread. What do you think? And are there any approaches that I might have missed?
(Of course, some of the overhead could be reduced by implementing my projectiles in C+±-but right now I’d rather not do that, especially for a side-project. I’d rather stick to Python.)