How to get accurate shoot and hit positions in FPS games? (Ping problems)

Since the player’s character movement takes a bit before it replicates to other clients, my shoot and hit positions are inaccurate from the client who’s shooting POV. How do games like Phantom Forces and especially Arsenal have such perfect shoot and hit positions? Because of ping, if they were to let the client who’s shooting see perfect positions, the other clients would see incorrect positions (such as shoot position away from character position) wouldn’t they? And if the other clients see perfect positions then client who’s shooting will see incorrect positions (like shoot position different than shootpoint position) wouldn’t they? Do they predict the movement of the client who’s shooting and if so, how is it so accurate?

I know the games render the cosmetic projectiles locally. What I am trying to say here is like when a client shoots, their hit position seems to be exactly where they are trying to aim. This doesn’t make sense, the server doesn’t know their aim position because of ping, and their shoot position is already ahead of what everyone else sees, so how in the world does the projectile look perfect from everyone’s POV while it deals damage at perfect hit position even though client who’s shooting is ahead of everyone else? The game seems to have no ping problems at all. What is this crazy magic they have created?

This topic suggested to use something called “paint”(?) where the client would send hit information to server and server would verify it with anti-exploit. How is this supposed to work? Wouldn’t the server and other players see incorrect hit position because they are already rendering the projectile?

1 Like

Most games with server/client replication and projectiles use different methods of lag compensation. This focuses on ‘rolling back’ the player’s positions to where they were on the client’s screen and checking this on the server. Since this can be quite complex and it has been discussed here before, I’ll give you a previous thread which explains it quite well:

3 Likes

I don’t really understand why I would roll back time. I’m trying to predict the future player position am I not? Wdym by where they were on the client’s screen? The client doesn’t see other clients before the server does it? I am very confused. Is the client supposed to send hit position to server and the server rolls back time to when the client saw the enemy? If this is the case, then by the time the client sends position, the hit position will be delayed because the client has already moved on

If hit calculations are done on the server, the server needs to ‘see’ the game as the player who fired sees it in order to detect a hit. You can’t, however, have both the server and client see hits the same and so the most common approach is to make the client ‘authoritative’ such that, subject to checks on the server to prevent exploiting, the client never sees any lag with their projectile hits.

However, this will result in situations where another client will be hit when they are in cover on their screen so you might want to take into consideration things like a maximum ping to prevent other types of exploiting. You will want to render the projectile immediately on the client and then send the position to the sever, which uses compensation to determine if the client preformed a valid hit on their screen.

in my game, the way i did it was

  • Make the client’s local script detect a Ray part and position
  • Send that information to the server
  • Send that information from the server to each client, excluding the original client.

If I do this, the hit position won’t line up with the projectile that everyone else sees. If I send the origin to the server, everyone’s projectile trajectories will line up but the trajectory origin will look detached from the shootpoint in other client’s perspectives.

There really aren’t perfect solutions in networking but you could try creating the same projectile on all screens by having the server send the ‘rolled back’ origin to all clients. This might not line up with where their weapon is now but hopefully this won’t be too big of an issue. Most games that use this, like CSGO, don’t deal with projectiles at all.