I have a Gameplay Ability for firing a weapon, everything appears to be running correctly. The ability is taking the correct amount of ammo (1 round) but is firing 2 line traces on each client and causing twice the damage, I assume it’s causing damage for each line trace.
This is a single fire using 1 round.
This is on the player character activating the fire weapon Gameplay Ability
The Fire Weapon Gameplay Ability replication settings
The GA Code part 1
The GA Code part 2
The fire function just removes a round from the weapon.
The “C_Perform Recoil” event just performs procedural recoil on the client and then sends the muzzle socket transform to the server to conduct the line trace.
This is the line trace performed by the server
The hit result applying damage
I assume I have a setting somewhere that is causing it to run twice and, in that point, causing the damage twice but I have no idea why or how to fix it. Anyone have any idea?
Debug by making the servers trace color purple. Post results.
Also, do not use the clients muzzle unless you scrutinize it against servers muzzle. Otherwise your providing a built in cheat.
If (client muzzle - server muzzle) -> vector length <= 3.cm : can use client, else use server
I have debugged and both are server line traces but ill grab a screen shot when i get off work. I have to currently use the clients muzzle due to the procedural recoil, the recoil is currently random and the server and client get 2 different results. For example the clients weapon would recoil up and left where the servers result would be up right so the servers line trace would be no where near the players aiming. Thats only temporary until i figure out how to send the procedural results from the server to the client or get them to match somehow.
You only apply recoil to the client. The pitch and yaw will automatically be sent to the server.
Here is the trace color on server set to purple.
What Net Mode? Listen/Client
If Listen, then when the host shoots you need to not RPC the server.
Host is the server.
Net mode is set to client, with both listen and client it shoots 2 line traces.
Another couple of issues.
Your getting the Muzzle transform AFTER applying recoil. This will never line up with where the client was aiming at the time of input. You should store the transform immediately on input.
Recoil imparts a pitch to camera rotation… above aimed at location.
You’re also using single player/coop nodes in your server code.
Get Player Controller (0) ALWAYS points to the Host (listen server) or first joining player (dedicated).
If player 2 shoots your effectively telling the server to use player 1’s controller.
Then client logic is calling the server twice somewhere in your code. What does the Fire
do?
Responsiveness wise the client should be doing its own local shot. Otherwise there will be massive delays. Imagine having a 100ms ping and trying to shoot. On press it’ll take minimum 130ms before you see anything happening. Closer to 200ms in reality.
Ok so I am an idiot, I am using a ballistics plugin (Terminal Ballistics) and I had “Simulation Net Mode” set to “Both” Server and Client… Putting it on Server fixed the issue …
1 Like
Fire only removes the round from the chamber as long as it doesn’t fail beforehand. Part of the inventory system
However, I think I’m going to play around with the other info you sent on my other question about the weapon fire GA and just remove the fire weapon from the ability system since it’s not using any kind of attribute or anything like that. But I’ll play around with both and see what one I like at the end. Thanks for the player controller catch too!
Prototype it in a blank project. It’ll save you so many headaches and clean up time.
1 Like
Point about muzzle transform
I disabled recoil application so you can see hit accuracy in MP (net mode client).
This uses the system outlined in the other post.
The crosshair is temporary for interactions and stuff; the line trace starts from the muzzle that isn’t lined up with the cross hair when not aiming down sights
You can see the trace is lined up with the muzzle but not exactly lined up yet (just because I haven’t put in the animation yet, so the rifle is just generally placed for now. It’s not intended to line up either, but it will be a lot closer than it currently is.
When ADSing it lines up with the crosshair.
In the screen shot that you referenced I moved forward a bit so you can clearly see the difference between the traces. Here is what it looks like without moving and putting the simulation back to both lol.
My projectiles spawn at muzzle and intersect the cameras trace downrange in both hip and ads. Very simple process. Trace itself isn’t technically needed. You only need a point down range centered with camera.
Trace End would be the Shoot At Point.
Aim Velocity is what you’d pass to the projectile to set PMC’s Velocity. This will have the projectile move toward the “Trace End” vector if spawned at the Muzzle Location.
1 Like
Red Line is Camera Trace
. It’s end point is Near Zero
Yellow Line is the projectiles trajectory path to reach Near Zero
.
This is how IRL weapons work. The projectile moves upward toward the optics “zeroing” point down range. At the projectiles Apex it should be dead on the Zero point.
ADS Shot
ADS Hit point mid zero distance
ADS Near Zero Intersect
Hip Fire Shot
Hip Fire Near Zero Intersect
Impact
Projectile hits should always be lower than near zero until intersect point.
Long range weapons like sniper rifles typically have a Zeroing of 400m or more. SR’s have a Near and Far Zero.
In projectile trajectory, far zero
refers to the second point where the bullet’s path intersects the line of sight as it descends back down after reaching its peak. This occurs after the initial near zero
where the bullet crosses the line of sight on its way up.
1 Like
Thank you, I am very familiar with weapons and ballistics as a recently retired army sniper
Thats why I am using Terminal Ballistics, “relatively” realistic bullet drop. If only I knew as much about game development lol. I really appreciate all this info. I have got more done with weapon fire today then I have in the last couple weeks
1 Like
Thank you for your service!

1 Like