Sign in to follow this  
jxwnhj0717

Help! How to implement accurate attack in client-server RPG?

Recommended Posts

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)

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this