Download

Multiplayer projectiles setup

Hi, i dont want to make wall of text so tldr:

i use projectiles at 5-10k speed

  1. server-handled projectiles are not accurate enough, clients see projectiles passing their mesh
  2. client sided projectiles does not working when player mesh is destroyed…

VIDEO for imagination:

https://www.youtube.com/watch?v=7LM1-QsYgcc

I need to advice, how someone solved projectiles in multiplayer game… please :slight_smile:

bump …

Bump…

up up …

Yo.

  • why would replicated projectiles “pass through meshes”?

  • I think you should not care about small position differences when replicating projectiles, only the Server projectile is the real one anyway and only it will apply the gameplay effects you want.

  • with your multicast projectile setup, try to add a 0 second delay before removing the mesh / collision of the player that was just killed and see if the client projectile still fails to hit it

Hi, thanks for reply.
Replicated projectiles pass through mesh, because when server hits pawn, clients get this “update” maybe after 1 frame´, so it looks like projectile passed through pawn 1m ±… it looks bad :frowning:
There is also problem that when pawn is near wall, projectile spawn 1 overlap and 1 hit FX but it should spawn only 1 FX on overlap…
Im very interested in this if its possible to solve this, but probably not because im finding answer over 3 months and still not successfull…

I wanted to try to delay destroying pawn’s mesh, but im not sure if this will work on clients with higher delay(ping)… I tried to get reference to multicasted projectile and destroy it manually, but i cant get it…

Are you using listen or dedicated server?

How many projectiles are spawned in your game in 1 minute on average?

How many projectiles are alive in the same time in 1 minute?

Have you heard about object pooling and projectile pooling in general?

When you tried replicated projectiles, did you also replicate their movement?

Tell me about how the projectile are supposed to be working: spawn with muzzle flash effect at the tip of the character’s weapon and then spawn hit FX when projectile hits something?

Tell me about how you deal damages, is it when the server’s projectile is hitting something? What system then takes care of the damage?

When do you destroy the projectile?

I think it’s perfectly fixable, we just need to think about this and see what are your needs and how we handle them.
Also it looks like the 4.14 version of Unreal has news about networking and netcode in general.

Just curious, 5-10k speed is pretty fast. Can’t you just use traces?

1. I will use probably both, dedicated and listen… At game launch i will probably let players launch their listen servers, but if there will be interest in that game, i want to make it running on dedicated servers…

2. Gameplay field will be for 8-16 players at once. AVG fire rate of weapons is about 0,3s so there might be spawned ± 1000 projectiles in one minute.

**3. ** Peak of live projectiles at one time will be probably like 30-50

**4. **I heard about pooling a little (enemy AI characters), but never about projectile pooling, but its sounds interesting

**5. **yes i replicated movement, im currently using there replicated projectiles because i dont know yet how to deal with destroying “deadly” multicasted projectile

**6. **Projectiles are spawned with muzzle flash FX, collision is set to overlap pawns and block enviroment. If projectile overlap me or ally, it continues in his way, if it hits enviroment (block), its stopped immediately on server and clients too which is what i exactly want, but i cant use it because then its blocking pawn movement. When projectile overlap enemy, its supposed to deal damage, spawn FX and be destroyed.

**7. **Curently im spawning only server projectiles, so damage is handled by projectile himself, but before i spawned 2 projectiles - first one on server with only damage handling, and second one with impact FXs and correct overlap-stop behavior. Works very well until server projectile destroy pawn mesh, then multicasted projectile can’t collide with mesh so continue on his way

**8. **Projectiles are destroyed when they hit enviroment or overlap enemy pawn, but before they spawn some FXs, and some projectiles (rockets with trail FX) are first stopped until FX trail is disappeared, and then they are destroyed

I have 2 traces (laser and sniper) but all others are projectiles for simple reason - anti aim hack :slight_smile: 5-10k speed is not that fast + i want to have fast game so pawn movement is currently 1k and i want to boost it with some “pickups” to 2-3k. so its almost impossible to hit player with aim hack because players must a little predict enemy movement

First thing to try is to just replicate the projectile without replicating its movement. If there is a projectile movement component on your projectile actor, it should follow the same path on client and server.

Then you can try multicasting the disappearing of the projectile when the server’s instance of that projectile hits something that should block / overlap it.

It might be bandwidth expansive with the high amount of projectiles you have though (I don’t really know). That might not be the solution to your problem but it’s one lead.

  1. So i tried to switch off “replicate movement” but without changes…

after maybe one frame is that projectile destroyed

  1. no no bandwidth, im doing all these tests with only server + client (= 0 projectiles in game)

  2. You mean that i have to destroy multicasted projectile, when server hits something? I tried this but its (probably) not possible to get reference to multicasted projectile… This way is good i think, last projectile won’t be 100% accurate (because networking communication) but it never mind 1 out of 10-100 its fine. But is it do-able? I tried to call every RPC and mix it somehow but i was unable to get reference to that multicasted projectile…

My concerns regarding bandwidth were about the implementation of my solution.

My idea was the following:

A replicated projectile without movement replicated.
When this projectile is supposed to be hidden / destroyed, the Server multicasts that event.

Didnt help :confused:
Im afraid of that i shouldnt use server-client calls because all are a bit delayed because of network…
I think that in other games, projectiles (except damage dealing) are handled by client so impact accuracy is 100%, but i dont know how to deal with destroying multicasted projectile…
I can’t delay firing damage projectile, and delaying destroying pawn mesh can cause some problems too because i dont know how long it takes to collide multicasted projectile with mesh…
Do you have idea how can be handled this? Thanks for help btw.

Quick thing before I begin - as a moderator, I gotta say : please don’t bump threads like that - wait 4-7 days at least.

Moving on.

Lag compensation, similar to UT4.

  • On firing, spawn projectile on client with a unique index and send a message to the server to do the same.

  • Include the unique index used by the client projectile, a timestamp, plus the actual location & direction.

  • On the server

  • Roll back players based on the this time stamp.

  • Spawn the projectile at the location & direction.

  • Run them all against each other until its has caught up to the server time.

  • Replicate the projectile
    [LIST]

  • For non-owning clients, include the origin so they can spawn effects they may have missed due to the catch up.

  • For the owning client, include the unique index.

Upon a client receiving the projectile

  • For all clients, run an additional catch from the received location based on 1/2 the clients ping.
  • For the owning client, use the unique index to find the client side version of the projectile and ensure it is in sync (or close enough).

[/LIST]

How you roll players back and by how much is up to you.
Whether you roll back other actors is too.
Either way, it should help compensate for differences between server and client, while keeping the server authoritative.

Hi,
Thank you for this, i have plan to do something like this (good ref this one), but now im trying to have accurate projectile impacts (overlap behavior,i want projectile to not pass through mesh).
Im trying to inform clients where projectile should stop. Server know this well, but clients not (because of network latency). I know that some people multicasting projectile and then projectile have accurate behavior, but last, deadly projectile, which kills pawn, can’t collide with mesh)

Hello everybody. I understand that already 2020. But still I decided to write an answer. I also had such a problem. My (Projectile) did not match on (Client / Server). The thing is that before I created (Projectile) in the world, I released (LineTrace) to indicate rotation for (Projectile). But (LineTrace) I released through (OnServer -> Multicast). That was my mistake. She decided when I released (LineTrace) for all players only on (Server). And transmitted the received coordinates (to Clients). That is, if you release (LinTrace) not on the server, then for each copy the calculations are different, because of the delay. Accordingly, the rotation for (Projectile) for all clients was slightly different.