Instant Networked Damage Numbers

How are multiplayer games like Fortnite able to show damage numbers instantly on a client, even though they have server side hit registration? No matter the ping (i tested it) the damage numbers show up instantly. I tried the same method, validating the damage on the server and spawning the damage numbers after on the client, but there is always a delay to spawn the damage numbers according to my ping because RPC’s take time to send.

Here is a video showing my game and my server hit detection

Floating text could be client-side predictions. Basically the client interpolates between the server’s updates and when it detects a hit, it fires off floating text.

If there is a range of damage/possibility to critical hit, you can bake the damage into the projectile so the client knows what to show if it predicts a hit.

Other than that, it’s possible for clients to handle that kind of logic and then for the server to validate the input.

If it happens instantly, it’s because of Client Side Prediction.

CSP is basically just the client going ahead and doing things before the server confirms what actually happened. Since the vast majority of games are Server Authoritative we have to wait for RTT to get an update on any action done by the player. That’s way too long for any player to wait, so the local client will go ahead and do some things without permission if it knows that they’re most likely going to actually happen. Movement is one example. You never wait for the server to approve your movement or it would feel incredibly bad! Instead, you apply the movement locally, send it to the server, and over time you might update that client to correct his position if there are any discrepancies.

Damage is the same way. If a client shoots and hits, you can usually safely assume that you did damage so just like movemeny, make the prediction. Up goes the damage pips, maybe kick some animation response, etc. When server returns the response, just verify the health is what the server says it is and get on with the game.

This video is a goldmine for netcode architecture.

Hi LaneFox, thanks for the quick response,

If the client spawns the damage number, but the server rejects it, the damage number is still going to be on the screen until the server sends an message to the client whose hit didn’t go though to take it down. This means the damage number is going to give false feedback. How would I handle that?

9898203--1429416--upload_2024-6-19_10-57-19.png

People aren’t going to be paying that close of attention. The false feedback doesn’t matter, the feedback at all does. Damage numbers like that aren’t meant to provide the player with accurate information, they’re meant to provide the player with dopamine.

2 Likes

You seem to be under the impression that this does not happen in AAA titles. It does :slight_smile:

e.g. In halo 2, one could beatdown(melee in halo jargon) a player at the same time than the other did. The animation, SFX, VFX would all play on the first client client, and then the first player would die and the other player would live undamaged. The prediction happened on the client, but the server processed the other player’s input first and rejected the first one’s. Games were also hosted on users machines but thats another story.

In later halos, they’ve decided against this behaviour and instead allowed a small timeframe in which both beatdowns would register. Essentially leading to both players dying. This behaviour is silly but it reduced the frustrations of thinking “Wow I hit him but I still died and he’s fine”.

Each scenario is going to be tailored differently to try to marry players expectations and fairness, but it is almost never perfect.

I very much agree with @Murgilod that essentially floating text hits are just juice

@Murgilod is correct, you don’t worry about these cases. The goal of CSP is to make relatively safe assumptions for the benefit of immediate feedback to the user and validate later with server authority.

You don’t need to take this too far, false information is fairly uncommon in practice, has minimal impact, and is tolerated by users by a large margin as long as the server is forgiving and/or favors the shooter. The more important thing here is that the player feels good about what is happening and that what is happening is responsive to their inputs. You can sort out problems where there are genuine issues later on a case-by-case basis.

Alright, I think this solves it! Thank you guys