Intro
Eternal Crusade Resurrection is a multiplayer shooter with extensive melee usage (swords, knives, other weapons) based on animations with root motion. We use GAS for all melee abilities.
Problem
Sometimes while fighting in melee, your opponent’s position (who is also fighting in melee and playing animation montages) can be replicated wrong during several seconds up to 10 seconds or more. It seems that it can happen not only when ping is bad (150 ms+), but also during rather good ping (40 ms).
6th second: enemy jump pack assault is attacking the box, but dealing damage to the player, apparently being in from of him on the server (ping near 120ms)
30th second: enemy tactical is hitting the corner, but dealing damage to the player, (ping is near 70ms)
4th second: enemy raptor is hitting while being in other location than on the server (40 ms)
Suspected main problem thesis: lack of replication of current position from server to simulated proxies or incorrect prediction from the simulated proxies overwhelming the correct data received from the server.
Melee implementation
Tracing, damage and stun application is done on the server only in N seconds after ability start.
Playing montage is done via PlayMontageAndWait GAS task.
Ending ability is done only with “End Ability Locally”, which is fired on both server and owning client at their time.
During melee and some seconds after it, Client Authoritative movement is used (to smooth animations for people with 100ms+ ping), in the end of ability validation occurs (end position - start position length) and in 0.2 seconds, if another melee ability wasn’t initiated, the movement becomes server authoritative back (the booleans below are set to false).
To prevent attack from mishit, there is a box in front of the character which accepts overlap events (on client) and freezes movement (by calling “Disable movement” and since movement is client authoritative) when another pawn overlaps it. In the end of ability the movement is enabled (by setting walking or falling mode depending on “is falling”).
Smoothing is disabled to give correct coords ASAP (below are character properties).
Attempted solutions:
- Disable client authoritative movement swap, check for box overlap events on server.
Results:
- Bad box overlap events, characters often seem to fly through each other during attack
- Unpleasant correction of your movement with high ping, interruption of abilities
- Seems that incorrect position replication from server to client still occurs
- Use custom function for replicating montage (reliable server and reliable multicast):
Results:
- Still incorrect positions of enemies hitting you but seeming to be in high distance / looking in other directions - didn’t help (3rd video is after applying this change)