Download

Where to handle weapon aiming & firing?

Hello everyone, I’ve been working on a project, and I have a pistol BP, and when I click LMB, my character fires a “Shoot” function in my Pistol BP, and it shoots. I tried to do this with multiplayer, but regardless of what I tried, I could not get things to work properly on my clients, so I placed my firing code inside of my character BP rather than pistol BP (My pistol is a child of my character’s camera). After doing this and getting it working, I started to wonder about what I should do to handle shooting & aiming once I start using a socket for my weapons rather than just a hard-coded pistol as a child component. Is it best to handle this stuff inside of the character BP rather than each individual weapon BP? Has anyone got any tips for me, or things that I should know about for weapon sockets? Thanks ahead of time for the answers.

I am curious about this myself, its pretty much what has stopped me messing with the engine for fun, no matter what I seemed to do I could not get a Gun to Fire from within its own Blueprint when it came to Multiplayer :frowning: I feel this is the way to go, I don’t need a huge list of each guns firing mechanics in my Character Blueprint.

“Is it best to handle this stuff inside of the character BP rather than each individual weapon BP?”

In most FPS, and TPS, aiming is done on the camera itself, not the gun. That’s why you see a crosshairs in the middle of the screen. Raycasting is handled by the player BP, while
the gun effects, such as muzzle flash, rate of fire, sound and damage are handled by the gun.
This makes it easier to line up shots.

In the FPS template, the character handles ALL of the shooting instances.

I hope I made sense, it’s hard to explain without going into detail.

Alright, but since all guns are of different shapes & sizes, what is the best way to make sure all guns aim correctly and aren’t glitching through the player? Is that just something to take care of when modeling the guns & adding the sockets?

Aim from the camera, not the gun.
That’s the way!!!

Well in my current setup, other players can tell when someone else aims in because the gun itself moves, do you suggest that locally, I move the camera, and remotely I move the gun?