Let's say I'm working on a 3D first-person shooter and the boss is a stickler for realism, and orders me to implement the bullets as tiny projectiles that travel, say, 1000 meters per second. What might be some implementation difficulties, gameplay experience changes, etc. that would result from that decision?
-
\$\begingroup\$ Actually AFAIK there are some games that do simulate the bullets. As long as you are using continuous collision detection it shouldn't have significant technical challenges or gameplay differences. \$\endgroup\$– akaltarJan 31, 2017 at 3:56
-
\$\begingroup\$ I have to imagine the a very practical reason that they're slowed down is visibility--take battlefield's beautiful bulleits saring through the air. I wonder how the bullets in battlefield would look if they moved 16.6 meters/frame as opposed to the speeds that they do: symthic.com/… \$\endgroup\$– James HurleyJan 31, 2017 at 13:30
3 Answers
The main problem is tunneling.
Game physics engines typically use discrete collisions. That means they advance all the bodies by one short time step, then check if they're intersecting, and handle collisions in response.
This works well for medium-sized objects at medium speeds.
But if you have a small object (like a bullet) moving very fast (like a bullet) then a single time step might take it from just about to hit some poor person's face to just past the far side of that person's head. Since the objects are small, they don't intersect in either position, and the physics engine says "great, no collisions to deal with!" and moves on.
But from a player's perspective, a bullet just went through someone's head without affecting it, like it had "quantum tunneled" through it.
Ways to fix this are:
Bigger, slower collision objects (you can probably get away with extruding the bullet's collider along its flight direction so it's more like a flying lance and more likely to intersect rather than tunnel completely through. You just need to make sure your gun doesn't hit you or things behind you when you fire it, or hit things on the far side of a wall if you shoot directly into it)
Smaller time steps, but this means more calculations which is slower.
Continuous collision detection, which models motion swept over time rather than as a series of discrete hops. This can be even slower still - especially against complex collider objects.
You may also find some physics engines rebel when you try to make objects travel above a certain speed. They might refuse, by enforcing an arbitrary speed limit on everything (usually a good thing, as it clamps how badly things can explode when physics glitches happen, and bounds the worst case for some calculations, helping us get faster & more predictable performance). Or they might behave unrealistically - a tiny 8-gram bullet sending a 200 kg soldier flying because the collision system doesn't handle momentum transfer correctly for such huge disparities in mass & velocity. You might need to treat the bullet as a trigger volume if the impact reactions get unruly.
-
\$\begingroup\$ doesn't max payne 3 feature something close to real time bullet physics? \$\endgroup\$ Feb 1, 2017 at 17:10
-
\$\begingroup\$ @RenaissanceProgrammer it might well. Having not worked on the game, I can't speculate on how they chose to implement their projectiles. As pointed out above, these tunnelling / max velocity problems aren't necessarily insurmountable, but they do require investment of developer time and runtime resources to solve. In some cases that will be a worthwhile trade, while in others hitscan methods are sufficient. \$\endgroup\$– DMGregory ♦Feb 1, 2017 at 17:13
For most games it doesn't make a difference.
Take the Counter Strike series, for example. It simulates firearms combat on rather short distances. On the distances where the average CS shootout takes place, the gameplay difference between the simple hit-scan solution and the far more CPU-intense physics simulation of bullets would be negligible.
On the other hand, there are also games which simulate firearms combat over far larger areas. When you fight over distances of hundreds of meters, bullet drop and bullet velocities start to make a difference. Such games can benefit from a more accurate simulation. But keep in mind that it makes the game harder to play. Players need to develop a feeling for how far they need to lead their target and how far they have to aim above with what gun on what distance. That means a much steeper learning curve and a much wider skill gap between newbies and experienced player.
Depending on the game, implementing realistic bullets would just be a waste of framerate. I mean, FPS's have plenty of moments where multiple people are firing at a massive rate, if bullet objects were to be pumped out like that. Say GOODBYE to 60fps.
-
\$\begingroup\$ This answer would be better if it described in more detail why treating bullets as fast-moving projectiles would have such a substantial framerate cost. Also, to evaluate whether this cost would be a "waste," we need to weigh it against any potential benefits the choice might have. \$\endgroup\$– DMGregory ♦Jan 31, 2017 at 5:57
-
1\$\begingroup\$ This is a very poor quality answer both in terms of actual information given and how it's given. We need to know why it's a waste and examples of when / when not to use it. If I didn't know better I'd flag this as a very poor quality answer. \$\endgroup\$– CharanorJan 31, 2017 at 21:23