FPS Ballistics Demo

I have always been fascinated with ballistics and firearms ever since I was a little kid.

3 minutes read

Platform

PC

Engine

Unity 4

Technologies Used

C# Unity

I have always been fascinated with ballistics and firearms ever since I was a little kid. I actually had the idea of making a videogame where you don’t just press R to reload, but you had to operate the firearm in every little action needed to get it ready to fire. Sounds familiar? Right, well, somebody else did it first! But I don’t think I’d have been able to do it better.

So, heavily inspired, I set out to make a quick playground to test around with ballistics. Since I’ve also always been a fan of the Sniper Elite series ever since the demo for Sniper Elite V2 dropped, I also wanted to play around with hit prediction. In that game, if you lead a shot on a far away target, the game calculates where you’ll hit it. Naturally I don’t know how accurate it is, but I figured I’d try to figure something out. So there you go, an attempt at a Receiver & Sniper Elite hybrid. I focused on ballistics and prediction first. I also liked the idea of procedural animations like Receiver does, so instead of using animation keyframes everything is animated by interpolating numbers around.

The slide and gun recoil is interpolated.
Lowering the gun and aiming it is also interpolated

I didn’t make bullets to be physical objects, they’re actually a zero-dimensional point in space that I move around with physics formulas, raycasting between previous point and next frame’s point. They probably were not super time-accurate especially considering I only really knew how to multiply by delta-time, wasn’t aware that non linear functions don’t do well when simply multiplying everything by deltatime.

Here you can see how bullets fired in the distance leave a trail, and the trail shows a parabolic path, like real projectiles.
This is a very basic implementation of bullet ricochéts, slow motion is enabled for this shot
Here you can see bullet penetration and the hit prediction in place, it’s detecting where the bullet will hit. Naturally, it assumes nothing will move after it passes through it, so it doesn’t account for physics cascades. In other words, it predicts based on the “snapshot” of all objects at the moment of firing. Also, it’s kind of frame locked. I was not able to predict on a fully frame unlocked ballistics algorithm, likely due to my deltatime inaccuracies.
This one is a slightly longer video for a demonstration of the hit prediction.