1
\$\begingroup\$

enter image description hereThe problem is as follows:

A receives the position of B as 40,40. Now, obviously this position is already out of date. On Bs screen B is of course already at 50, 40. Now A shoots at an angle from 15,0 such that it would hit B (bullet has drag and gravity). When this information "shot from 15,0 angled at X". If I now render the bullet it's obviously going to miss because now B is already at 70,50. But the player aimed at 40,40 + predicted trajectory.

The image shows this situation from both A (left) and B (right) perspectives. Blue really got hit (because it counts what A can see of course. If it hit from A's perspective then it is a legit "hit") but the visuals are just off obviously.

So how do I render the bullet trails correctly?

The only solution I see is for A to display B not at the position the server told A but extrapolate the position such that it displays B where B is predicted to B when the information about the shot would arrive at B. Now this has obvious caveats because we don't know if B has stopped already so this would allow you to shoot players that stopped right before they would pop out from behind geometry because we predicted B to pop out.

But this would allow players to "aim correctly" such that the bullet trails would appear correct on the receiver (if the prediction is correct).

\$\endgroup\$
1
  • \$\begingroup\$ Comments are not for extended discussion; this conversation has been moved to chat. Please edit the question to include relevant details or refinements to the focus discussed in the comments/chat, so that it can read as a concise and accurate snapshot of your most up-to-date understanding of the problem. \$\endgroup\$
    – DMGregory
    Commented Feb 3, 2022 at 16:44

1 Answer 1

0
\$\begingroup\$

You could do two things. You can look into Rollback netcode to resolve your issue by looking to synchronize the player input from the client's side.

Another simple implementation to fix it could be to slow down the speed of the bullet to give the server enough time to receive and send the information from the other player. And, at the same time, when the info is received, you can accelerate the movement of player B so that he reaches his "real" position faster.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .