Upcoming Events! Community Event Calendar
Social Media Follow us, or not!

Bugsmashers: Episode 36 Written Friday 11th of November 2016 at 03:00pm by StormyWinters

Mark Abent is here to save the day with Bugsmashers!

TL;DR (Too Long; Didn't Read)

As is with any information on our transcripts and summaries, everything posted is subject to change by CIG and in some cases may not always be 100% accurate at the time. While we strive for accuracy, mistakes do happen so please let us know if you find something amiss that we didn’t catch. Enjoy the show!

  • The bug is grenades don’t work properly in multiplayer, when you throw them they just fall to the ground and explode instead of traveling some distance and in this instance is a case of serialization
  • A physics controller handles all the properties the designer would need to set physics on an object and the grenades are a type of physical thing and when you throw it it’s supposed to basically serialize all the information
    • The server will see it far away and the client will get the network packet and also see it far away but this is broke  
  • A bit of code was added for a previous bug that tries to serialize the state of physics and handle it for items, vehicles and things that use the physics controller  
    • This code was put into a spot so all of them could share the same bit of logic but it never got put in for items due to legacy reasons and items have something called a profile manager and if it’s in there it doesn’t run
  • They can serialize things like a rigid body’s(in this case the grenade) position, velocity, etc. The network needs a constant flow of information and if you’re a rigid body, the position and velocity always has to be serialized
  • The server was sending position and velocity but when the client got the packet it wasn’t expecting anything and disconnects the player
  • The fix is to strip out a block of code and place it before because they don’t want the code to run if they have the physics controller whether or not they have the profile manager, always want to serialize it into there
  • So if a rigid body is sent and you’re stuck in some kind of physics it’ll handle all the information by doing a garbage snapshot and read in the position and the velocity
  • Next is getting rid of the capture profile manager and move it into the physics controller so it takes care of all the profiles

Full Transcript

Mark Abent: Hey everyone, welcome to Bugsmashers. I’m your host Mark Abent, if you guys have never seen this before, it’s pretty cool. I take you behind the scenes of both Star Citizen and Squadron 42 on how we develop and basically destroy these bugs, you know, when we’re developing things… things go haywire all the time and I’m here to show you some bugs that get smashed… YEAH! Let’s smash some bugs.

Hey everyone, we are here in my fancy, dancy test level… if you ever seen this before I like to play around and have a bunch of things in my level so I can test all sorts of things and in this particular case I broke grenades in multiplayer. So, hop on top of the ship and if I try to throw a grenade… it kinda just falls down and then it does an explosion, oh god I’m going to die. Phew, I got away.

So, the grenade should be thrown, travel some distance, not a footbal length but you know some distance, oh I fell. Unfortunately when you throw a grenade they just plop to the ground and they just stay there and they explode and everyone around dies.

So, what’s happening? Well, an unfortunate case of serialization. So, we’ve been moving a lot of stuff to these component subsized things where instead of jamming all this logic into one block we separate all this logic into different blocks and then we can take some of this logic, this logic… stick it onto this item, stick it onto this item and designers can go crazy building these building blocks. Designers get these lego sets, it’s pretty cool and one of these lego sets is this thing called a physics controller. The idea of this is it handles all the properties the designer would need to set physics on an object and these grenades are a type of physical thing called a rigid body and when you throw this grenade it’s supposed to basically serialize all the information. The position, velocity and all that fun over to all the other clients… so the server will see it far away and the client will get the network packet and also see it going far, far away but unfortunately that broke.

What happened was earlier we were getting some disconnects on this guy, the ship, whenever the ship got destroyed it exploded and disconnected everybody. So, what I ended up doing was, where’d it go, ah there you are...we have this thing called a game object where it’s like kind of the root legacy component system before we started doing our stuff. We’re trying to get rid of it but we’re still stuck with it and any time physics or anything that syncs, it goes through basically this block. So, I added this little bit of code here that tries to serialize the state of the physics and handle it for items, vehicles and these things that use this physics controller because prior to this they were all doing it individually and it was a whole nightmare mess.

So, I put it into one spot so that all of them could share the same bit of logic but unfortunately it never actually got in here for items because due to legacy reasons, items have this thing called a capture profile manager and in here if we have a profile manager it doesn’t run. This profile manager ideally is if we change physics we can change what stuff we serialize so if we have a rigid body we can serialize position, velocity, all that jazz if we have something that’s static we just need a position but the network needs a constant flow of information so if we’re a rigid body we have to always serialize that position and velocity. If we miss the velocity we get disconnected, if we’re static we always have to do position, if we do anymore or any less we get disconnected.

So the profiles is kind of a way to say, ‘hey we’re in this state, now we’re in this state’ so it serializes the right information and the server was setting up the rigid body so it’s sending position and velocity but the client wasn’t expecting anything. So, when the client got the packet, it was like, ‘what the heck, I don’t know what to do’ you get disconnected.

So, with that fun jazz I was hoping to solve it with this, however I didn’t take into account the silly profile manager. So the fun fix is to actually strip out that fun block and put it before because we don’t want this code to run anyway if we have a physics controller whether or not we have that profile manager. We always want to serialize it into here because this old way would disconnect you if you weren’t the right type, well this guy would serialize it if you’re in the incorrect type or not.

So if we do send the rigid body but if we’re still stuck in some other type of physics it’ll actually handle the information by doing this thing called a garbage snapshot where even though we’re in this state when we expect just position it will also just read in that velocity or position. Just to say, ‘all right we’re not in sync yet but we will be soon’ and this guy handles all that. So, we make sure the game rules, oh I’m sorry, the game object goes through this path so everything will be fine and dandy.

The next thing we have to do is get rid of this capture profile manager on the item itself and the vehicle and I redid that for you and move it into physics controller so he takes care of all the profiles. All right so unfortunately we have to restart the whole game. All right, the magic of recode in editing is finished, we’re not back in the test level so we’re going to go kill Bob here with my grenade.

So I’m going to stand back here, throw my grenade at him. Oh there go...oh I missed him… no, I hit my hand, I’m going to die, awe.  Well things never work out as you want them in game development but as you can see when I throw a grenades they actually move now even if they hit my hand. Good times. All right hope you guys liked that bug.

Ah, the wonders of game design. You know I try to fix one thing if you’re in a ship and you get disconnected I’m like, ‘Ah, here’s a good solution’. Then I get an email saying I broke grenades, oh, good times. You know we’re still dealing with these legacy systems as we bring on our new systems and it’s just the constant battle to make the two in balance until we’re finally able to say, ‘hey old system go away and new system take over control’. So fun little thing with the net serialize, everything got sorted, our vehicles now serialize correctly, our grenades serialize correctly. No one gets disconnected and I can throw grenades at Bob and he explodes in glory, haha. Good times. Well, hope you guys enjoyed, this was Bugsmashers, I’m Mark Abent, Gameplay Programmer here at Cloud Imperium Games in good ole Los Angeles. Hope you guys enjoyed, til next time.

StormyWinters

Director of Fiction

Moonlighting as a writer in her spare time StormyWinters combines her passion for the written word and love of science fiction resulting in innumerable works of fiction. As the Director of Fiction, she works with a fantastic team of writers to bring you amazing stories that transport you to new places week after week.