Multipleyer Spring Arm doesint inherit, pitch, yaw or roll

Hello, I am trying to learn how to make a multiplayer FPS with UE4.
I successfully made a fop character, the gun and shooting. But I am having trouble with the multiplayer.
The way I set up my character is, he has a camera, which is connected to the head. And from the head there is a very long spring arm. This is from where to where my gun shoots.

It works perfectly on the server, but it doesn’t on the client.
If for debugging purposes I attach a cube to the spring arm, and also shorten it.
We can clearly see the problem.
Server from clients POV:
Screenshot 2022-01-03 201215

Client from servers POV:

Screenshot 2022-01-03 201407

And when I shoot the bullets go either in the sky, or, in the right direction.
I have enabled replication on everything i can i have also made all of the functions to RUN ON SERVER.
Btw i am using blueprint.
Thanks in advance.

The weapon seems to be doing fine so can’t you just remove the SpringArm and use the Weapon’s muzzle location to shoot? Is there a reason why you need a SpringArm?
If the Weapon doesn’t have a socket for the muzzle end, then make one.

Thanks, i had a muzzle at the end but i used the object attached at the end of the spring arm to get the perfect midle of the screen, and set its rotation. But the problem is my gun is constantly moving do to his moving animations and when he dose, he doesin’t shoot acuratly i am now trying to find a way to get the perfect midle of the screen. The spring arm worked on singleplayer but not on multiplayer.

Hi again, i acheeved the same result with a line trace, but as u can see from the screen shot only the server shoots straight and only the server can see the line trace even tho i set the function as run on server.
I think the problem is with the replication of the camera.
But i have component replicates enabled on everyng.

I understand what you mean.

Ideally, you want the bullet to spawn at the muzzle (unless something is blocking the muzzle). You don’t want the bullet to start from the centre of the screen do you?
It’s the direction (rotation) of the bullet that you want to change.

There’s many ways around this but one option is to use APawn::GetPawnViewLocation and APawn::GetBaseAimRotation. This should give you the location and rotation of the crosshair. (Only works on server and owning clients - other clients shouldn’t need to know about this info anyways).

Do some vector forward magic and now you have the direction.
You can even compare it to the muzzle direction to decide if it’s ‘close enough’ to use. If it’s too far (let’s say 30 degrees off), then interpolate between the two directions, if completely off, just use muzzle direction. If you decide to do this, you need to make sure the multiplier you used to get the forward vector is the same for both (I.e. 10,000).

If you want even more accurate results (which for an FPS I suggest), then whenever the Client sends the RPC to the sever to fire, also send the current ‘crosshair direction’. This is because the server’s copy will be slightly out of date and inaccurate. To prevent cheating, you can get the server to validate it by checking if it’s close enough to the server copy (if it’s too different, just use server direction).

1 Like

Wow great!
Thank you verry mutch!
I will defenetly implement at least one of your sugestions. :+1:

Shoot from muzzle.


YOO thanks, i rly wanted a whole solution :+1:

Latency will have a huge impact on this unless you implement something akin to Rewind Time. Essentially character buffering. You’ll also need a solid network clock. UE’s default implementation can be off by a sec~.

Average latency in most shooters is around 80ms. Yet you will have quite a few players with 100ms+. It’s not uncommon to see a good chunk of the players on a server with pings over 200 and up to 500ms.

Server provider/network/topology has a huge impact on this. Cloud vs DC rack etc.

You’re welcome. I do have a velocity based variant of this as well. If interested let me know and I’ll post it.