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

BUGSMASHERS!: Episode 28 Written Wednesday 15th of June 2016 at 07:39pm by StormyWinters

What? Who’s this? It’s Mark Abent! Check out Mark’s return to Bugsmashers with a transcript to boot!

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

  • Ship spawns half in the landing pad
  • See it a lot in multiplayer, not often in single player
  • When a ship is spawned they get a callback that they can then look up the code to see the landing position and move into proper position
  • Callback was happening after the ship already spawned and then they had to move the ship
  • Code relied on the fact the ship was spawned to get that position
  • Went back into their XMLs and pre-calculate the offset and put it into their implementation XML so they know the offset before the ship is spawned
  • Have code that’ll get the vehicle params and spawn location and move the spawn location
  • This math will get the world matrix, apply the offset in world space to get the new location

Full Transcript

Mark Abent (MA): Hey everyone, welcome back to Bugsmashers, sorry we didn’t do it last week. I was at E4 everyone, now that was horrible but I am going to go to E3. That’ll be fun, you wish you were there, I’m gonna be there. You wanna go there? We’ll meet you there. All right, let’s start the show.

Hey everyone, we’re here in my fun little port, Port Awesome, as you can see everything here is awesome except there’s one thing not awesome. When I spawn some ships then, they seem to be falling through the ground. So, let’s spawn in our Scout ship. Ship is spawned, I have powers to go through walls because I’m in Port Awesome. Wee!

As you can see my awesome ship is no longer awesome and it’s teleported out spawn inside of the level, joy. Normally this wouldn’t happen in single player but you guys will see this a lot in multiplayer. You spawn a ship, sometimes instead of it spawning on the platform, it just spawns inside and goes…[mimics explosion with hands]

So, what’s happening… let’s go to the code. So, when we have a ship and we spawn it, we get a callback saying their vehicle has spawned on the server and then we have some code here to look up the landing position and move the ship into the proper position. However, let’s use this awesome pencil… if this is the origin of the ship [points to middle of the pencil] and this is a landing gear [holds post it note pad up beside it] and the origin is here [points to middle of the post it pad], I’m going to spawn inside and explode [holds middle of pencil against middle of the post it pad].

So, we have this thing right here which is the landing pad helper and the idea is to have a position right here [indicates tip of the pencil] saying this is where the landing position should be, not the spawn origin [indicates middle of pencil] so going back here [holds up post it pad again] instead of spawning here [holds middle of pencil to middle of post it pad again], I’ll spawn like this [places tip of pencil to middle of post it pad].  

The only problem is this callback happens after we spawn and what we’re doing is we’re actually positioning the ship here [places mid pencil to mid post it pad again] and then the callback happens and then we move it up [repositions pencil to place tip on mid post it pad]. Not good especially since it may take a little bit before physics physicalizes and all our items get on, so we may spawn here, an item may pop in [mid pencil to mid post it again] and then all of the sudden we’re intersecting things, things explode and not good.

So, instead of putting our position in, you know, after we spawn… we have to put it in as a pre-requirement to our response. Instead of spawning here [indicates mid post it pad], we have to spawn at the offset [indicates distance between mid pencil and tip of the pencil]. So, if our spawn point is here [mid post it pad], we need to calculate what our theoretical offset would be which would be right here [indicates distance it would be from mid post it pad], so we’re going to spawn on the top instead of on the bottom.

However, we can’t do that right away cause this bit of code relies on the fact the vehicle is spawned and we can get that bone position. So, what we had to do was go into all of our XMLs and pre-calculate that offset, stick it into our implementation XML so that we know how far we’re off before we even spawn a ship. If we get rid of this lovely code and actually go where we request the spawn. I have this new funky bits of code that’ll get the vehicle params and get the spawn location and move the spawn location.

If we go here, go from the top down we’re going to set up our vehicle spawn and we’re going to tell it to spawn at this spawn location [indicates middle of post it pad] but we’re going to apply an offset where the vehicle params says, ‘hey, you need to move this much from the origin of the ship’. So we take that position and here’s our spawn [middle of post it pad] and we’re actually going to move it up [indicates distance]. Now our new spawn offsets up here.

That’s what this fun little bit of math will do, it’ll get our world matrix and it’ll apply the offset in world space so we get the new location. So now when we’ve pressed our spawn we get new location instead of teleporting there or spawning here and moving up. So, let’s do some recode and give it a try.

All right, so we just did a recompile of the code so let’s fly off, all the way back into our ship spawning which should be… here we are. Let’s respawn…no, gotta wait 30 seconds, luckily I have developer mode and I can cheat with time. Take a second to go away. Request our ship spawn again, teleport, weee and voila. Our ship is now in the correct position because we spawned it in the correct position rather than in the incorrect position and then move it back.    

Now there is still some bugs where…I think it was with the Aurora where after we spawn it, it slowly rotates around but that’s a whole other fun physics thing, maybe another Bugsmashers, until then see you guys.

So, we had a little fun bug here with our landing system and we were spawning a ship in the ground and then moving him up, when we should just spawn him into the correct offset. So, we hooked up that code, made sure that any spawns, you know, offset correctly and now you won’t spawn and see your ship explode into a billion pieces. You will see some fun things like the Aurora twisting around but that’s just an issue with how we’re dealing with physics and the landing but that’s a whole other thing. Probably get to it eventually on Bugsmashers but until next time, see ya.    

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.