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

Bugsmashers: Floating in Oblivion Written Wednesday 26th of April 2017 at 12:00pm by StormyWinters

As per usual, anything said during the show is subject to change by CIG and may not always be accurate at the time of posting. Also any mistakes you see that I may have missed, please let me know so I can correct them. Enjoy the show!

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

  • Bug is where when you spawn into a single player match and if you don’t touch any buttons, the player will start floating above the ship and just keep going

  • The attachment system is being too optimal in combination with the physics grid giving the player a slight velocity while changing zones and the velocity accumulates

  • The fix is to tell physics when the player is in the seat and stuck to an attachment he shouldn’t have any velocity, clear the velocity         

Full Transcript

Mark Abent: Hey everyone, welcome to Bugsmashers. I’m your host Mark Abent and I’m a Gameplay Programmer here at CIG, LA and I take you behind the scenes of some of the ridiculous bugs we have. Hope you guys enjoy, let’s start the show. 

All right, we are here in the fun, fun main menu and we got a fun bug where when the player first spawns into a single player match, like Free Flight or Survival mode or whatever you want to play in single player and if you don’t touch any of the buttons, the player will start floating above the ship and then just keep going and going and going forever. I did not believe this was true cause it sounds ridiculous until I tried it and I swear I was laughing for a good ten minutes. 

It’s so ridiculous and so awesome, I just started a match, let’s let the loading screen go and now we’re there and everything might look normal but we’re actually ascending into oblivion. If I actually, use free cam, you’ll notice that the player is not in his seat because he is floating somewhere in oblivion. I don’t know where he is, he’s up there somewhere, if I do free cam disabled one… he’s floating far, far, far, far away. 

You can kinda see the… were moving. It’s so weird, what’s happening. Well, this took me down a long, long rabbit hole. So to start off we have a ship and we have a seat and then we also have, where is… we have a player. We stick the player onto the ship by an attachment using the good old attachment system and in theory when the ship moves and animates, the player will get snapped to the position. 

Unfortunately or fortunately our attachment system is a little too optimal in a good way. Where if our ship isn’t animating or isn’t moving, it doesn’t necessarily need to move any of our attachments, so that means if our ship is staying perfectly still, we’re not shooting, we’re not flying, we’re not doing anything. In theory we do not need to move the player to this position or any of it’s guns or items because it’s position is always going to be the same and that’s what these beautiful bits of code do her. 

So, that’s why our player’s actually not teleporting to the seat. The reason why he’s not moving is because the good old physics code decided when we transition from one zone to another zone or the world to inside the ship, we need to maintain his velocity relative to the zone. That includes a bunch of things such as you move and your rotation and all that fun jazz. During that specific calculation it decides to give the player a slight position due to good old floating point resolves. 

So he’s moving really, really, really tiny and it’s just accumulates really, really quite a bit. So get around that fun stuff, in the attachment the player animated character… this handles the player’s actual skeleton and stuff like that. We have specific areas where when he animates it updates relative to the attachment and all that fun stuff. So, what we want to do is when he’s in this specific state, we want to just clear the velocity. Just in case he happens to get some, so what we’re going to do here is we’re going to use, what is it… I closed all my fun stuff. 

There we go, so we have this thing called pe_status_living which we ask the physics system cause the player is, we call him a living entity, it’s his physics type. We have rigid, we have static, while the player is living because he has ragdolls and all that fun. We have this structure called pe_status_living which we’ll fill out a bunch of interesting information. Particular information we want in physics is this velocity which is what you… when you press a button to move or you’re moving to that zone as I was saying, this is the velocity the player has so he can move through the world. If this is not zero, what we want to do is now tell physics to clear all of his velocity and rotation because when he’s in the seat and stuck to an attachment he shouldn’t have any velocity. 

Just so happens switching from zones does give him a little bit. So, we’re going to disable velocity if he ever has any. So, let’s hit the magic recode button. Actually we don’t have to recode, we’ll just build because it’s pretty simple to replicate this one since we have to go to the main menu and then to single player. So, we’ll let that build and then we’ll start up the game and see what happens. 

Sorry, I don’t have bacon today so just going to be drinking coffee while it gets done. All right, we’re back to the main menu, go to Arena Commander. Wait for more loading, then single player, go to our Free Flight and then we go to some more loading. I love these line rides, they’re the best. Now if I don’t touch anything, I should still be in the cockpit of my ship. There we go, so I’m no longer floating away into oblivion I’m actually still in the ship and everyone’s having good times. Ridiculous bugs, hope you guys enjoyed, until next time. 

So we had a fun little bug here where if you join into a map and you stay absolutely perfect still, the player decides to ascend into oblivion and well that was just our backend attachment code deciding to be a little more optimal than it needed and our physics code deciding, ‘hey, let’s give the player a slight velocity when we change zones’. With those two combinations having fun and doing their thing, it was the perfect storm to send the player off into where ever he wanted to go. It was a quick fix to make sure that if he’s in the seat and he’s done that zone transition just to nuke out any velocity so he stays in the ship til he’s ready to move with the ship sometime later. Hope you guys enjoyed, until 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.