I am planning to develop client-server RPG, but I get stuck in accurate attack. Think about under situation:
1. Player1 at position A in server.
2. After 100ms, Player2 see Player1 at position A, but Player1 moved to position B in server side.
3. Player2 attacks Palyer1 at position A.
4. After 100ms again. Server receives attack packet, But Player2 moved to position C, if Player2 attacks Player1 at current position C, the hit will always miss.
I need estimate attack time:
Command Execution Time = Current Server Time - Packet Latency - Client View Interpolation
This formula from:
https://developer.valvesoftware.com/wiki/Source_Multiplayer_Networking#Lag_compensation
But how can I get Packet Latency and Client View Interpolation?
I read the unity network demo of TPS-Auth. I think Client View Interpolation should be equal to fixed time + Client Latency.( GraduallyUpdateState.cs m_InterpolationBackTime property)
Help! How to implement accurate attack in client-server RPG?
Started by jxwnhj0717, Nov 02 2012 09:37 PM
1 reply to this topic
Sponsor:
#2 Moderators - Reputation: 3293
Posted 03 November 2012 - 10:31 AM
When you have such small timespans, your game really works like an FPS or fighter game. You should look at the Valve/Source networking article to see one approach, which involves placing the attacked player "back in time" to the time of the attack to see whether the attacker hit or not. Another option, described in the "GGPO / Fight the Lag" article in a recent Game Developer magazine, is to hide the attack latency in the wind-up animation -- basically, you play the wind-up on the attacking player's machine, but not on the attacked player's machine (or at least you drop the part that started before the packet got there.) This works well when the attack animation is "fixed" and can't be controlled once started.
A third option is to realize that 100 milliseconds is really hard to tell for most players -- it's a very small amount of time! You can show the attack on the attacking player's machine, but you only need to show the "hit or miss" after you get the data back from the server on how it went. Many FPS-es do this by showing guns firing right away, but showing blood spurts or whatever from the target only after the server has sent a hit-detect message back.
A third option is to realize that 100 milliseconds is really hard to tell for most players -- it's a very small amount of time! You can show the attack on the attacking player's machine, but you only need to show the "hit or miss" after you get the data back from the server on how it went. Many FPS-es do this by showing guns firing right away, but showing blood spurts or whatever from the target only after the server has sent a hit-detect message back.
enum Bool { True, False, FileNotFound };






