Projectile Start Location On Dedicated Server Not The Same As Client

UPDATE 12-06-2021 Problem Solved
To fix: On your skeletal mesh component of your character, set Anim based visibility option to Always Tick Pose and refresh bones
TOJX6MiD3b
Special thanks to KaosSpectrum#0001 on Discord for figuring it out, and thanks to everyone else who tried.

Hi,

• My game uses a dedicated server.
• My player character spawns a blueprint weapon in it’s hand
• When I need to fire a projectile the clients character asks the server to fire a projectile. I have a custom event to RunOnServer. Off that custom event it goes to my weapon interface.
• Inside my weapon blueprint I have a StaticMeshComponent and that mesh has custom sockets setup on that static mesh. One socket it named Muzzle.
• When the weapon blueprint receives the “Event Fire Projectile” (interface call I made) that goes to a custom event to RunOnServer and that spawns the projectile. It spawns the the projectile but by the characters feet. I know I have the socket “Muzzle” correct because if I change the custom event from RunOnServer to Multicast the projectile spawns at the “Muzzle” socket and also by my characters feet. I’ve been working on figuring this out for 2 days and it has to be something so simple I am skipping over it. Maybe I need a break haha. It seems that the server isn’t getting the spawn location or something.

Below is a pic of how I’m getting the socket location for the projectile to spawn.

This is racking my brain someone please help lol

Are you passing the projectile location into the Server Event that spawns the projectile, as that should do it for you.

Thanks for taking the time to help me out. I tried that. In my WeaponBP I spawn the projectile off the interface call, right after that I put a custom event to RunOnServer and then that spawns the projectile, still spawning at the feet. I shouldn’t have to do and RunOnClient events to get the socket location right?

Sounds like the Static Mesh Component isn’t replicating properly after reading your initial post again, possibly?

When you click on the in the heirachy is Replicates, Replicates Movement, and Net Load on Client Root checked?

Edit: Changed Static Mesh Component to Root

I’ll check, I just edited my post above and put a screen shot up

1 Like

The screenshot looks good to me on initial glance.

It might be SmoothSync but I’ll try what you suggested

Ah think I found it. GetSocketLocation returns a local location and you need a world location. Try GetWorldTransform off the Static Mesh Component.

EDIT: GetComponentLocation seems to be preferred

Thanks, I’m redoing my BP_Masters to see if they need to be setup differently

@Cipher5

Straight forward approach with Server Auth on projectiles. This “reduces” potential cheating.
e.g. clients passing illegitimate transforms, thus shooting through walls/cover etc.

For demo purposes I coded this up directly in the character class. Typically you want fire logic in the weapon class.

This should work well out of the box for very low ping game play (sub 50ms). Beyond that you’ll get discrepancies in client/server aim. Meaning a moving client will predict a hit where as the servers projectile trajectory will differ.

This will be especially noticeable if you add client-fakey simulation. e.g. client fires a local only “fake” projectile for responsiveness.

Ping mitigation will require extensive work. You’ll need a reasonably accurate network clock, server-side player position buffer and usage of projectile path prediction. Essentially setting up “Rewind Time”. You want the server to be spawning the projectile with the same transform/velocity as the client did based on where the client was and was aiming at that specific moment in time. Projectile path prediction will enable server and firing client projectile syncing.

3 Likes

UPDATE 12-06-2021 Problem Solved
To fix: On your skeletal mesh component of your character, set Anim based visibility option to Always Tick Pose and refresh bones
TOJX6MiD3b