Fighting ping lag in pvp combat

So I’ve been playing Rogue Lineage recently and I’ve noticed how drastically your ping affects your gameplay advantage.

When you left click to throw a punch in Rogue Lineage, the client side sends a signal to the server and then the server does the punching. There’s no client-sided feedback either. Depending on your ping, there can be very unpredictable/long delays between a Left Click and your character punching. This can be problematic in fast-paced pvp games.

Problem: There’s a inconsistant/random delay between when the user Left Clicks and the character punches.

Cause: The server’s not receiving the message fast enough because of ping

What solutions are there to help even the playing field with ping lag in pvp combat?

A potential (but bad) solution could be to have

Client sided combat collisions

So the client side throws a punch, detects what it hits, then sends the server a message of what it hit.
This gives lag switchers and exploiters a huge advantage.

Another solution I thought of was

Tick based actions

Instead of having the client tell the server to punch as soon as possible, why not give the server more time to receive the message? Why not create our own predictable delay?

The server and the client both have a built-in clock that stays synchronized at roughly the same time. This clock is unaffected by network lag. It works just like a regular clock. (See tick() under global functions)

Instead of telling the server to punch as soon as possible, the client side sends the server a future/upcoming tick time. When the server’s clock reaches that specific tick, the punching initiates.

For example, if the client is at tick time 100, it sends the server a message of 100 + 5 or “105”.
When the server receives this message, “105”, it waits until it’s current tick reaches 105 and then makes the character punch.

On the client side, attacking has a windup of 5 seconds, and then the punch. The network has that entire 5 seconds to send the message from the server to the client. (By my testing, you can lower that to around 1-2 seconds)

When I tried messing around with this concept, I realised there’s a lot more that goes into combat than just when you punch. Where you punch is also a fairly big factor. Positioning your character is still tethered to your ping. This might make when you punch more predictable, but getting punched would still be based on where your character is positioned. You’d still be at the mercy of your ping to move your character out of the way when avoiding a punch. A possible solution to that could be to reduce player movement speed.

Is there any point in bothering with these nuances?

What do you think?
I hope this wasn’t hard to read.
Typing all this out has helped me process it.
I’m open to further clarifying anything if needed.

2 Likes

First of all, think about these questions and reply with an answer.

  1. Does it take long to load?
  2. Is the amount of parts in the game causing this. if so, try deleting some parts in the game.
  3. Have you tried lowering the graphics or making the game have less graphics?
    Turning up graphics and/or making thousands of parts could cause a high ping.
    Final question: What is your ping?

Answer these and Ill get an idea on what to do.

1 Like

Your tick based actions idea is completely feasible in certain cases but unfortunately, there is no real synchronized clock between the client and the server. Tick() is different per host machine (client), if you look around on the forum you’ll see topics all over the place about this.

Although, a game called Rocket League has some pretty amazing ways of practically removing latency in its fast paced, input heavy game play. I didn’t read too much into it but this Reddit post might give you some ideas.

https://www.reddit.com/r/gamedev/comments/6fol5h/how_does_rocket_league_do_their_physics/

2 Likes

This is something that I’ve had issues with recently as well. My game has a melee combat system, and the way that it works is the player handles animations on their own, and tells the server when an attack should happen. The primary thing I’ve noticed with this is the positional lag. Many of my players have told me how frustrating it is to see a hit that should do damage on their screen, yet it does nothing. I’m honestly not sure what could be done to circumvent this, because it’s just a side effect of latency and the physics replication of characters. Honestly I’ve just decided that kind of hit latency is more worth it than giving an advantage to lag switchers or exploiters.

2 Likes

@XxJonnyDaBestxX

  1. The game doesn’t take too long to load (especially considering it’s a theoretical game)
  2. There are two parts inside the game
  3. The game has practically no graphics
    Final Question: I’ve changed studio’s settings to test out a variety of different pings. So far I’ve tested pings 0, 150, 300, 600, and 1000.

I’ll take your suggestion to reduce large amounts of moving parts into account.
As for graphics; Network lag is a little different than normal physics/computer lag. I’m mainly interested in how to deal with clients being unsynchronized with each other.


@Stratiz

I did say roughly the same time. In theory, tick() should always return how many seconds has passed since January 1st 1970. Being a few decimals off shouldn’t make too much of a difference. From my personal testing, they were off by a few hundredths of a second, but they were basically in sync.

As for the stuff about Rocket League, that’s really interesting. So the physics are run on the server and the client, then the client rewinds stuff and fast forwards with new inputs to match the server? Isn’t that what Roblox does? Or does Roblox just tween things and not rewind things? Roblox potentially has a lot more moving parts than Rocket League though so that’s something to keep in mind.


@SebastianAurum
That’s exactly what I’m talking about!
The only plausible way to solve this seems to be by slowing down movement for everyone, just so that the networks of the few who have high ping can keep up.

I’m interested in any other possible solutions.

2 Likes

Depending on your time zone, tick() could be off by different multiples of 3600 seconds + additional seconds depending on how a user sets their system time. You would have to find a way around that.

1 Like

Oh thanks for mentioning that! I’ve only done tests on my local machine so this piece of information is very informative.

1 Like

In a previous iteration of my combat, when all of the hit detection was handled on the client, there was a movement mechanic which used stamina to propel yourself forward at a constant rate. It’s frustrating, but when I switched to server-side hit detection I had to remove this mechanic because nobody was getting any hits when trying to use advanced movement mechanics with server sided hit detection.

Also: mini rant here. When I first got to work on converting my hit detection to work on the server instead of the client, something that was a very common thought in my mind was “Well linked swords have server side hit detection, and those seem to work great!” But after dealing with this latency I’ve realized that linked swords don’t actually handle hits on the server, despite what the scripting would imply. This is because Roblox offloads physics, including the .Touched event, to clients when they have network ownership. This is also why exploiters can still use “reach hacks” despite the hit detection being handled on the server. Basically, Linked Swords cheated and I’m salty.

1 Like