Download

Projectile replication and networking discuss

Hey guys, first post here.

So im wrapping my head around projectile replication. I googled much for the last days, and tried out some things but i want to discuss this topic and i want to ensure that my informations are valid.

Im making an autoattack where a stone spawns in front of me and is shooting towards where im aiming. I use the projectile movement for this. The game should be competitive so -> server authoritive and everybody should be as near as possible to servers version of game. I will use a dedicated server

So there are 3 ways to do this in network ( correct me if im wrong or there are more ways)

  1. Ask server to spawn the actor and set it to replicate so it gets replicated to the clients.
    -There is an input delay depending on the ping
    -The replicated movement looks buggy to clients (is there a way to optimize this? tried to use interpolation with setting a interpolated component and updating with move interpolated component in tick event with repnotify servers actor location and rotation but doesnt make much better)

  2. Use Multicast without replication
    -Seems to be pretty responsive for all clients but if i understand it right everybody has its own version of the actor which is not synchronized with the servers one?
    -I read that multicasting is network exspensive and that you should avoid it if possible
    -With multicast i could exclude the server from spawning the actor but instead just predict the projectile with the function predict projectile path. Would i save server ressources with this? are there other problems with this idea?

  3. Replicate is but spawn it on the owning client directly
    -so its very responsive but the owning client will see two actors when the server begin to spawn its actor. So i make an RPC to the owning client to destroy his actor if the servers actor is spawned. That looks not satisfying. I tried to “smooth” the local actor towards the server actor and if the positions are equal enough then i will destroy the local actor and he sees only the server one. But then the server projectile still doesnt looks smooth.
    -Another idea is that the servers actor will only replicate to other clients except the owning client who has his local version. Of course just the servers projectile will fire hit events and so on. But there are two things in my mind with this:
    1.I think, escpecially with high ping, it would be very frustrating to see that you hit an enemy but server didnt. So you deal no damage. I KNOW that this is common in games, this happens
    and i cant avoid this. But i think with this method it would be too much if you know what i mean.
    2.I dont know if its possible to replicate an actor excluding one client. U could achieve this effect by using multicast but i try to avoid it for the autoattack. Is there another way to to this?

So my main problem is that i dont know how to make a replicated actor with projectile movement look smooth for everyone with a normal ping but will also feel responsive to the owner. High ping client will always see a snap back or something. What is the “standard” procedure in the game industry for this? And for information: I use 12000-15000 velocity for this actor
I tried to play with projectile interpolation i think im not using it the right way, neither im sure if projectile movement use this automatically if im enabling it. I dont find much about that in the internet is this a new feature or is it just not the way to go?

I tweak netupdatefrequenzy for the actor. increasing it seems to smooth it a bit but first i think for an autoattack which will be spammed a lot u dont want have this set up to 200 or sth like this and second if the server is updating the position 200 to the client but the server only has a tick rate of 30 ticks it wont make such a difference or do i mess up something?

What are your thoughts, opinions and best practices?

Sorry for some double-spaces in the text my space is broken :smiley:

Best approach is client fakey. You gain client responsiveness and still maintain server authority.

Client spawns local fired projectile with collision -> RPC’s server to fire. Servers projectile is authority on hits, dmg calc, dmg apply etc. Server replicates to all other clients.

Server hits (auth confirmed) execute blood splatter. This alleviates some of the high ping variance frustration. Players can only really assume a hit if they see blood splatter. Just to be clear you’ll have LP vs HP misses and vice versa with any server auth setup. You can mitigate some of the low ping shot misses using a frame history time buffer, but it’s a very complex process (refer to Rewind Time hit detection).

For projectile lag comp you’ll want to use delta and predict projectile path to sync proxy projectile positions. On all other clients (non firing) you’ll spawn the projectile at the original transform, but maintain Fx/sound on the muzzle…where ever it may be at the given time.

Battlefield 4/1/V (EA/DICE) use this approach.

1 Like

Hey Rev0verDrive,

For the projectile lag compensation: Which tools or methods gives UE4 already that i can use? Can i use projectile Interpolation for this or is it already used ?And you mean: write this in the projectile movement class so that every client predict next movement?

You said “Server replicates to all other clients”, but how can I exclude the client which has already shot? (If we dont use Multicast)

Thx for your anwser!