Playing with netcode

Tue 24 Jan 2012, 07:41 by bencelot



I'm in the process of making some big updates to Subvein's netcode. Hit detection in particular. I'm going to implement a similar model to what most commercial FPS games use, which will make things a lot more fair and enjoyable for players with higher pings. It's a bit more advanced than what is happening at the moment but the benefits will be worth it. For tech minded people you can read about how it's coded in the source engine here (go to the Lag Compensation section): https://developer.valvesoftware.com/wik ... Networking

What I'm going to do is make it so laggy players are actually able to reliably hit bad guys. I will do this by creating bullets BACK IN TIME on the server when a player shoots. The system we have now is pretty good but it feels a bit sluggish and provides an undeniable advantage towards low ping players. This new system will make the game a lot fairer and more enjoyable when playing with a higher ping, 200ms for example. Having a lower ping will still have an advantage, but it will not as as extreme as it used to be and should provide for a fairer game all round. It will also make the game FEEL a lot smoother for high ping players (which most players are considering how few servers we have) which will be very important when we're trying to attract and keep newbies after v0.7 comes out.

Before I explain the old vs new system, just know that there will be a drawback to this new approach. There has to be. It is physically impossible to overcome the speed of light and thus unless we're all playing on a LAN something MUST be sacrificed in order to make the netcode work. The way it worked before the laggy player took all of the disadvantages and the low ping player had all of the advantages. I originally designed it this way because I figured low ping players shouldn't be punished because other players had a high ping. I've now changed my mind on this and think it's best to try and make the game as fair for everyone as possible. As I said before, high ping players will always be at an advantage, but at least now hopefully if a player with 200 ping is against a player with 20 ping it'll actually be a fair fight.

Time to explain some stuff! Suppose player A has a ping of 200. Due to the lag when player A clicks his mouse to shoot, there is no way that the server can actually know this yet. It will take at least 100ms until the server knows that player A has shot (only 100 because a ping of 200ms is the time it takes to go from the client to the server and then back to the client). Now if player A is using a Railgun or something, he might see on his screen that he's hit player B before the server even knows that player A fired his gun! Now ideally the game should be coded in such a way that if you see someone get hit on your screen, then they actually DO get hit. Not only does this make the game feel more responsive but it actually affects how we aim. Players shouldn't be required to aim extra far in front of their targets just to compensate for their ping. If you hit, you hit.

So the problem is this. By the time the server knows that player A has fired his gun, player B may have already moved positions from where player A was aiming. So how is the server going to hit player B when he's not even in line with the bullets trajectory any more? If you just create the bullet on the server and fire it as normal it's just going to miss. Even if you speed that bullet up heaps on the server to compensate for the time lost due to lag it still won't matter because player B has simply move away from where you were aiming. So what do we do? Well there are a few ways to deal with it.

The way we currently deal with the issue is to make player A's bullets APPEAR to travel slower on his screen. Because his bullets seem to travel slower player A will naturally aim further infront of player B as he runs along to try and hit him. His bullets go slower so he naturally aims further forwards and then sees his bullets hit player B. Meanwhile the packet of information is sent to the server who fires his bullet at NORMAL speed but because player A is now aiming in a different direction (due to his bullets appearing slower) it all lines up just perfectly and player A's bullet actually hits on the server! Hopefully that made sense :p The PROBLEM with this approach is that 1) it looks very weird and sluggish for your bullets to be travelling at half the speed that they should be, and 2) it's just a downright disadvantage in combat. Even though the game slows your bullets for you allowing you to use them as a visual guide to lead your target, it is simply far harder to hit a moving target with slow moving bullets than with fast bullets. This is why Energize is useful, fast bullets make for easy aiming. The system of hit detection technically works, but it does so at great expense to both the enjoyment and competiveness of the laggy player.

So what can we do instead? Well it's about time I update the net code to use the same approach professional games like CS and BF3 use. What these games do is instead of slowing down the appearance of player A's bullets, they let his bullets travel at normal speed on his screen and instead create his bullet BACK IN TIME instead. By letting his bullets travel at normal speed on his screen not only do his bullets feel normal again, but it makes it nice and easy to aim too. So what do I mean by create the bullets back in time? Well what happens is this. Player A aims his railgun at player B and fires. He sees the hit and would expect to deal some damage. 100ms go past and the server finally receives this fire command. In this time player B has moved to a different position, but as far as the server knows player A is still aiming at player B's old position. Instead of just creating the bullet then and there and hoping it hits, the server will actually rewind the positions of all the players in the game back to when it thinks player A actually shot the gun. So the server rewinds player B back 100ms to when he actually WAS standing infront of player A and then creates the bullet. It then simulates the flight of the bullet and player B's movement as per normal back until the current time again. Now what happens is that player B does get hit because his position was temporarily moved back to where player A was shooting. The end result is that player A sees his bullet hit player B, it does hit, AND his bullet doesn't have to slow down to compensate for the lag. Awesomeness!

There are a few problems with this approach though. Firstly suppose you're player B. You run behind a corner and take cover. You think your safe. All of a sudden you see player A fire a bullet to where you WERE standing 100ms ago and suddenly you die. WTF you think? WTF indeed. On your screen you didn't get hit, but on player A's screen you did. However I code the netcode one of these screens needs to be wrong, that's just the unavoidable nature of the speed of light and high pings. But I think it's far more important and enjoyable for you to actually hit when you see you hit, than for you to get killed on the rare occassion when you think you shouldn't get killed. Not only does it make the game a lot smoother and responsive for everyone, but it makes it a lot fairer too.

The end result will actually be a combination of these 2 approaches that will try to balance the pros and cons of each method to make the game as fun and fair as possible. I'll need to tweak this a little bit but I'm confident that the end result will provide a much nicer feeling for everyone. Even people who live in the US and currently enjoy the privilege of playing with low pings should benefit. You will no longer have an absolute advantage over everyone else so yes, your average KD *will* suffer slightly because of this.. but just remember that having a low ping is still giving you an overall advantage. But even low ping players will see an improvement in their hit detection as the current system is still causing their bullets to miss frequently, especially in close range combat.

P.S. The way the current system works your bullets are slowed but it takes a while for it to become in sync with the server. This means that at extreme close range fighting your bullets simply aren't hitting your target. This will all be fixed with the new netcode, and will probably have quite a large impact on the balance of skills and weapons such as shotguns, blade fury, radiate and other close range things.

Discuss!


8 Comments


GelatinOverlord says:

Tue 24 Jan 2012, 08:36


Well, Like in BF3, I don't like dying a half a second after I get to good cover. (Or proning outta sight) I like the idea though..
Also, Wouldn't this make the low pingers think they're lagging when they get headshotted through a wall by a 200+ pinger?
By all means, Do it, But first come out with new content.. You still haven't told us how far you've gotten in zombies, And the community is slowly dying out..


STM1993 says:

Tue 24 Jan 2012, 08:47


So doing this will make every player effectively have the aim advantage of a 0 pinger but the defensive disadvantage of a 300 pinger. Very big impact on gameplay especially for close range combat and maybe sprint.

Qwerty basically summed it up: I'm fine with this being implemented, but we're still waiting for Outbreak and we've not gotten a response on how much you've done for it.


Rex Nex says:

Thu 26 Jan 2012, 15:22


This is more important to overbreak for me. I was really hoping you would implement this widely-used system; as a end user, this really makes or breaks a game for me. The less I feel hampered by my hardware and connection, the more I am inclined to actually get better and not blame it on lag. I am very happy to see you have changed the netcode in this way; this is so much more enjoyable.

Getting killed while you are behind cover is annoying, but no where near annoying as emptying an entire clip into someone and dealing no damage because he is hosting the server and you have 200 ping. *ahem*cash*ahem*


bencelot says:

Fri 27 Jan 2012, 05:37


Yup I agree. Anyway it's only taken me a day or two to code it in, so that's finished now. Bit hard for me to test until I can play on a server with a big ping, but I think it'll be a big improvement to gameplay. The solution I've come up with however is a hybrid between the previous system and the new one. Subvein faces challenges that most FPS games don't, the main one being that you can actually SEE the bullets. In CS the bullets are invisible. In BF3 they travel really fast and you can't see their trajectory too well due the first person view. But in Subvein they're right there and easy to see. If I went with the CS system 100% it'd look really strange to take damage when you can see your enemies bullets and they don't even appear to be hitting you (on your screen). So the issue isn't just the behind the corner thing, but also just running about in general combat. Anyway I've come up with a pretty good solution which combines the two.. we'll just have to see how it goes!

Anyway, back to Outbreak :)


GelatinOverlord says:

Fri 27 Jan 2012, 08:33


Can you please give us a general time for when Outbreak is going to be released? A week? A month? A Moon Cycle?


darkqrc says:

Fri 27 Jan 2012, 11:22


your work is realy hard i hope you can finish it easily.Are you doing it alone?


Cash says:

Tue 31 Jan 2012, 09:49


*Pbbt* is what I have to say.

I now realise the complete futility in any sort of non-LAN competition in Subvein. Quite the disappointment.

The new system will definitely make the game more appealing to the casual player, which makes up the majority of players.


mrwtf says:

Sun 05 Feb 2012, 17:23


thumps up and hats off if youre doing it alone :O

Blog Posts For Geneshift


Version 1.04: Geneshift Miami!

(0)


Version 1.03 Adds New Camera!

(0)


Version 1.02 Adds Three New Skills!

(0)


Geneshift has launched on Steam Early Access!

(3)


Geneshift v1.00 Released!

(0)


Play the Multiplayer Demo on Steam Today!

(1)


Geneshift hits Steam on May 23rd, 2017

(0)


Official Discord Chatroom

(0)


Geneshift v0.997 Released!

(0)


Geneshift Launch Trailer is Live!

(7)


Server Downtime

(0)


Geneshift v0.996 Released!

(1)


Steam Store Page is now Coming Soon!

(0)


Steam Integration & Achievements

(12)


Geneshift v0.995 Released!

(1)


Geneshift - new game name!!

(4)


3D Vehicle Models!

(36)


3D Player Models!

(34)


Time for Graphics!

(10)


Skill Casting Guards!

(6)


Campaign Stage 6: Inferno

(6)


Updating the particle system

(2)


Stealth speeds by Outbreak in Speedruns!

(1)


Version 0.994 released! Introducing Stealth mode!

(0)


Graphics fun

(2)


Trigger music with bombs and text zones

(1)


Making Music!

(22)


Version 0.994 test build is available!

(22)


Started work on the third campaign stage: Driving Downtown

(4)


Just fixed an 8 year old bug with MASSIVE performance gains!

(2)


Guard Waypoints!

(59)


Version 0.992: Speedrun Leaderboards and new skill scaling!

(0)


Leaderboards are done!

(2)


New Version, new trailer, new year!!

(17)


Finished the new trailer!

(3)


Hooray! My laptop can take video!

(0)


Version 0.99 Released!! Amazing graphics and new chemicals!

(6)


Rewording all the skills

(8)


Working on team chemical vision!

(15)


FINALLY finished map making! Thank god.

(3)


Free skill resets on mutants under level 30!

(11)


Reworked Barn, Canal and Asylum

(9)


Reworked Downtown

(0)


Added the Newbie Checklist!

(7)


3D Models!! Mutant Factions has finally gone 3D baby!

(19)


Just rented an apartment in Peru!

(0)


Update on plans and Menu Music!

(9)


Massively expanded the in-game tutorial guide

(0)


Textured, Animated, Layered and 3D Fog!!

(5)


Specular Highlights!!

(6)


Added Ambient Occlusion!

(5)


Sexy Soft Shadows!1

(11)


Version 0.98: Some nice balance changes

(1)


A little bit of graphical goodness!

(0)


Brasil trip is over, back to coding!

(2)


Version 0.97: Chemical Warfare polish and skill queues!

(0)


Introducing Chemical Warfare!! Version 0.96 is here!

(0)


Chemical Warfare is finished!

(1)


Chemical Warfare: Graphics finished, coming out soon!!

(0)


Chemical Warfare: super sexy chemical graphics

(5)


Chemical Warfare: Today I finished coding all gameplay!!

(1)


Chemical Warfare: buy menu icons and descriptions

(2)


Chemical Warfare: carrying a chemical graphics

(0)


Chemical Warfare: buying chemicals

(0)


Chemical Warfare: compound graphics!

(5)


Chemical Warfare: HUD, networking and compounds

(0)


Chemical Warfare: point scoring and compound discovery

(6)


Chemical Warfare: menu, networking and compound locations

(0)


What's this blog business??

(0)


Version 0.95! New cash system!

(3)


Version 0.94!! FLAMETHROWERS!!!

(16)


Version 0.936 is out! Superweapons galore!

(7)


Please tell your friends and vote on Steam Greenlight!

(2)


Wooot Woot! Version 0.935 is here! No longer in alpha!

(10)


Check out the new main page!

(8)


Version 0.93!! Brand new ranked servers and CC system!

(3)


Rescaling of Respect Ranks

(2)


Version 0.92 is out! Sexy new maps and Outbreak changes!

(3)


4 new custom-maps servers

(3)


I'm going to be working on Mutant Factions full time again!

(10)


Mutant Factions v0.91 is out! Introducing Respect Rankings!

(4)


Outbreak has been released! Introducing Mutant Factions v0.9

(4)


Subvein has changed names to Mutant Factions!

(7)


12 Official New Servers!

(7)


Mutant Factions Madness: Official Play Sessions!

(12)


Subvein version 0.74 has been released!

(2)


Like Subvein on Facebook!

(8)


Subvein version 0.73 released!!

(13)


Let's Play Together!

(1)


Explosions now dynamically light up the map!

(5)


Subvein is on Steam Greenlight!

(54)


An amazing optimisation!

(12)


Version 0.71 has been released!

(1)


Version 0.7 is out! Translations, Unicode, and New Skills!

(5)


Today I'm going to add translations (переводы)

(34)


Version 0.698 is out! Vehicle netcode and skill changes

(2)


Version 0.697 is out! Restructured weapons, skills, missions

(6)


Version 0.696 released! Improved netcode, AI and skills!

(30)


Playing with pathfinding

(30)


Playing with netcode

(8)


Version 0.695 is here :D

(21)


Subvein v0.694 is rockin' OUT!

(6)


Subvein v0.693 is LIVE!!

(15)


Latest developments: In-game quick levelling!

(41)


Version 0.692 is out!

(9)


New version is out! Introducing v0.691

(7)


Yehaaa!! Version 0.69 is out!

(4)


Woo hoo! We now have new hosting :D

(10)


Woohoo!! Over 5000 members!

(4)


Subvein is back up and running!!

(8)


2000 members. Let's make it 20000!!

(36)


Subvein version 0.6 has been released!

(13)


New promo video!!!

(12)


Added a new Community page!

(6)


Just added camera shake :)

(3)


Updated the news page!

(3)


Start earning community credits today!

(16)


A war is coming..

(6)


Account system coming to Subvein v0.6!!

(29)


First ever demo of Subvein vehicles is up!

(5)


Version 0.551 Released :)

(4)


Subvein version 0.55 Released!

(8)


Version 0.541 is out. Thank god!

(5)


Version 0.54 is different. Experience it now!

(9)


Version 0.54 comes out in 24 hours!!

(9)


Subvein v0.53 is OUT!!

(3)


Subvein v0.53 will go up within 24 hours!!!!

(9)


Added a new SHARE button!

(2)


Added a new FAQ section to site!

(5)


Subvein version 0.52 is HERE!!!

(13)


Subvein v0.52 will be released in 7 hours!!

(13)


Development towards version 0.52:

(70)


Version 0.51 is OUT!

(6)


Welcome to Geneshift!

(167)