3 ms·
> ballistics aren't really computationally complex I’m not sure I would I agree with this. Even hitscan projectiles for a game like Call of Duty or Battlefiel
by forrestthewoods 7y ago
> ballistics aren't really computationally complex
I’m not sure I would I agree with this.
Even hitscan projectiles for a game like Call of Duty or Battlefield is intense. Dozens of players running around with high rate of fire machine guns in complex geometric environments. It’s a significant cost.
Ballistic trajectories are pretty complex. Adding primitive bullet drop is definitely a huge increase in computational cost.
And that’s just for fake ballistic. Real bullet ballistics are “solved” empirically. There’s a bunch of formulas with a bunch of coefficients. And real bullets are fired at a real range to calculate the coefficients. It’s crazy complex.
https://www.jbmballistics.com/ballistics/calculators/calculators.shtml https://www.jbmballistics.com/ballistics/calculators/calcula...
- sillysaurusx 7y agoMemory costs tend to dominate server side environments rather than CPU usage, though. How often is a player firing a gun? Every player in fortnite could fire at once and that’s still only 100 parabolas. Even if you devoted yourself to creating the most realistic bullet simulator, I would bet $10 that you’d be able to run that on any server that normally runs videogames. Pretty sure I’d go home with $20 in my pocket.
- forrestthewoods 7y agoTracing a parabola into short segments isn’t too horribly expensive. Intersecting that parabola with static and dynamic world geometry is less cheap. Fortnite used to have pretty bad early game performance. Games are defined by their worst case. Early game could have a few dozen players firing high-rate of fire weapons. 100 server shots per second would be a regular occurrence. Non-hitscan projectiles might also increase networking costs. Although for fast-moving invisible bullets you could probably don’t need to send them. The actual server cost for shooters is generally resimulating the world for each player. Adding simulated bullets would make this even more expensive.
- sillysaurusx 7y agoI think unless a profiler is telling you it’s expensive, then there is almost no chance you’ll guess it correctly on a modern CPU. I’ve done it a couple times, but I’ve been wrong far more often. Why are a few hundred raycasts per frame expensive? In detail? I was doing a few hundred raycasts per frame back in 2008 at 60fps. So all this talk about expensive raycasts strikes me as “someone hasn’t tried it.” Physics engines are so advanced that it’s mind boggling just how much work goes into their efficiency. There are legions of programmer-physicists who have spent their entire working careers just getting another 5% efficiency out of their algorithms. I could buy that 100k raycasts at 20fps might be expensive on modern machines, in specific circumstances. But 100? No chance.
- forrestthewoods 7y agoCasting a ray into a world with millions of triangles is not terribly cheap. Tracing a parabola through that world is significantly more expensive. Tracing an arbitrary trajectory with simulated drop/drag is even worse. Game servers often run at a mere 20Hz or 30Hz. Getting to 60 is hard. The question isn’t merely “is it expensive”. It’s “what’s the worst case and how expensive it is to add on top of what we already do”. Is 1 millisecond a lot or a little? (Spoiler: it’s a lot) Modern CPUs are fast. But single threaded performance hasn’t improved exponentially. You could technically throw cores at the probably. But games want to maximize total server instances. You’re not likely going to throw 8 cores at one instance. Go download Unity and find a reasonably complex scene. Start calling Physics.Raycast with different locations and directions. See how many calls you can make in 1ms.
- sillysaurusx 7y agoCasting rays into a world with millions of triangles is in fact pretty darn cheap now. Again, I will wager you $10 that you can cast hundreds of rays per tick with zero perceptual loss in performance. If you drop by 1ms for 100 raycasts, the physics engine is broken. I mean this in the nicest way: have you tried it? If you do, you’ll discover you can cast almost as many rays as you want, against almost arbitrarily complex scenes. Whatever the server is using for its physics representation (which you need anyway) is what rays will use. And you’re already simulating some physics at 20Hz. I used 60Hz to point out I was already casting hundreds of rays at 60Hz in 2008. Servers have only gotten better and faster, and the scenes have become exponentially more complex. But if you won’t try it, you won’t try it. I can’t really think of any other way to make the point, short of pulling up a chart showing how many millions of raycasts you can do now against scenes with millions of triangles. The whole point of spatial data structures is that you don’t have to check millions of triangles, even if your scene has millions of triangles. I think unity has caused a lot of harm in the sense that devs have no idea what it’s actually doing. Ray.Cast might as well be black magic. Is it expensive? Who knows? Maybe it takes 16ms per raycast! The worse part is that Ray.Cast also becomes the lens through which devs view the world. If unity’s raycast system is slow, then suddenly “all games everywhere cannot do this thing.” But unity is often slow!
- LgWoodenBadger 7y agoWhat’s complicated about the entry-level kinematics equations that you can solve by hand with algebra and learn as a high school student?