Combat System Lag and Ping Issues

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve?

A combat system with m1s, m2, block break, parrying, etc

  1. What is the issue?

When you m1, you play the animation local side so that its smoother and has a quicker response. However, I want to play a stun animation if you get hit but this means I would have to tell the client to stop it’s current animations and play the stun animation instead, otherwise, the client getting hit won’t see them getting stunned. An example of such an incident is when a player gets block breaked so their local block animation would have to be stopped and they would have to immediately play the stun animation.

What I would like to know is the proper way to do this kind of system as in whether I should play the attack animation on client side or server side and how I should play the stun animation so that everyone can see it played responsively instead of it being delayed due to a client’s high ping.

Right now my system looks kind of like this:

On attack:

Attack animation played local → Fire server event → Server detects hitbox and makes targets take damage or get stunned

On Stun:

Server fires remote event to client (if the target is a player) → player recieves message and stops all current animations and plays stun animation

From my personal experience as someone who has worked on many different combat systems, some not necessarily involving close melee combat:

It’s better to play the attack animation in the server:

  1. Players want to know when their attack actually starts, where it actually is, etc. to the server. When you play it in client, regardless of your ping being 50 (and most players play at higher ping than that), it’ll only actually play to the server a few miliseconds after. This slight difference can make big differences in complex combat systems because players can’t have exact reactions or predictions of their own moves.
  2. Having to play it in client requires you to tell the client to do that somehow. It’s way more convenient to just do it in the server. Also, the difference of smoothness of the animation compared to when it’s played in server is not even too much or something to worry about in general.

About the stun animation:

  1. Simply play it when you need it to in the server. Way more simple and convenient. It’s not necessary to make the client play it.
  2. Just stop all animations in the server too before playing it. A way I personally used to do that is with this code:
local function StopAllAnimations(animator: Animator)
   for _, animationTrack in Animator:GetPlayingAnimationTracks() do
        animationTrack:Stop()
   end
end
2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.