Whats the proper way to have a gun firing a projectile? (4-27) (5.0)

Hopefully, I can explain this well… I’m autistic and not that great when it comes to explaining things. LOL so, I’m not sure if maybe what I’m thinking just isn’t “how it’s done”? Because everything I’ve found online says otherwise. I’m working on a somewhat more realistic shooter (Like Tarkov, Insurgency, Ready or Not).

So, ideally, I would like to pick up a gun. Have the player fire said gun (If equipped), and that gun then fire a physical projectile from the gun that damages actors. Not doing a line trace/hitscan. I am working on stuff with realistic distances and proportions. Maybe that’s a terrible idea. But I’ve set up several maps and have been trying to get the ballistics in order so it behaves at least somewhat accurately. Reacting to wind, temperature, and even different bullet factors… Like the grain, muzzle velocity, and muzzle energy. If I can ultimately just turn the game into a giant true-to-life ballistic calculator that would be great. LOL.

The reason I say this is everything I’ve seen online has always just been basically just spawning the projectile from the player…

So for instance, if I have something like BP_Rifle that holds the mesh for my model. Then a BP_Bullet that actually has the bullet mesh, velocity, collision, etc. for the bullet. When the player fires the gun, it should go from BP_Bullet to the BP_Rifle blueprint, and then finally the BP_Player blueprint right?

I haven’t really seen much of this for Unreal. The only thing I’ve seen thats close to what I’m doing is a plugin for Unity (4) Realistic Sniper and Ballistics System - Trailer - YouTube

ANYWAY, everyone always makes the projectile just come from the player. Probably because it’s easier to make the firing input and projectile spawn? idk.

Maybe it’s just a moot point or nit-picky. Does that just not matter and I’m overthinking it?

And I know you can parent the firing of the projectile to a socket on the rifle. I already have that, not talking about that.

Hopefully it makes sense.

1 Like

Hi!
No worries about the autism, you are in good company i would say :wink:
Now on to the questions, the “How its done” simply does not exist.
There are many way’s this is done. Ofcourse its generally a hitscan vs object
type of model. But so many different ways to implement.
One thing to consider is that if you want a more realistic firing of bullets you always have to take the physics in to account. Not just the physics of how bullets work but the actual physics of the engine itself. When you fire a physics object at high speed at close range you sometimes get very unpredictable behaviour with the bullet just going through the object instead of colliding.
I watched a gdc talk from i believe the insurgency guy’s(that also use unreal)
That had a mixed system, they use a hitscan bullet for the close range to prevent physics glitching, and after some amount of meter’s that would spawn the actual physics object for longer range travel.
Anyway, if i would set something like this up i would split each part into its own function/bp.
The player has the ability to pickup the items,weapons and press the reload/fire/change fire “commands” that get’s called on the weapon they have equipped. Then each weapon itself has its own contained function that control’s its own behaviour like ammo type/count spread etc.
Then each ammotype has its own stats that give it its velocity/penetration/damage etc. So it would be a player->weapon->bullet order of events.
So when player has a weapon equipped he can press the fire button, then the weapon would get the call to fire, but check’s if it has ammo. if not then it would simply click empty. I think in this way you have a general setup for weapons and would allow you to make many different types of weapons and ammo independent of the other systems.
Hope this helped in some way :slight_smile:

1 Like