Star Citizen: Bugsmashers! - Here Today, Spawn Tomorrow
Transcript — every row opens the video at that moment
- 00:00:06
[Music] everyone welcome to bug smashers it's a whole new year it's a whole new fun and it's a whole lot of new optimizations so I have here a fun little test level that I use all the time and we are going to show some new stuff that we're working on and you have yet to finish but hopefully we'll bring a lot more optimizations as we make a bigger and bigger world one of the things that we have issues with now is let me just spawn into the game anytime I spawn an entity say a Cutlass the game takes a
- 00:00:57
while to load that Cutlass in and it basically stalls the entire game so if I'm in multiplayer and some guys spawns a ship on the other side of the universe my game will halt because I have to load it in not fun the reason for this is because when we load in this ship and all of the assets and all the things that need it it all happens in one continuous block on the main thread so as you're running the game we have to spawn stop everything load in everything spawn the ship then we could continue on not very efficient and physically this is our interface we want to spawn a ship in this particular case and it's a it's a blocking spawn everything halts until it is finished and then we carry on our merry way instead we want to use this
- 00:01:45
idea that we want to spawn this entity but let's have it in the background and when it's ready then we'll handle it so a lot of the guys in the UK and in the Frankfurt Studios have been building in this framework that allows us to do this it's not quite ready but it is there in a way that we can start utilizing it so let's get rid of this blocking spawn and instead we're gonna spawn a ship we gonna do my magical ship and she's you system I can't type for anything we're a spawn identity with our spawn properties that tells it where what and when and a new
- 00:02:35
thing is because this is going to be an asynchronous call like before as soon as we spawn it then we could access it we can't access this right then and there because it's not gonna spawn now it's gonna spawn maybe a second maybe two seconds later so we can't handle anything immediately so we need to say when this is spawn here's a call back or a function call back saying this is bond I want to handle it this way so we're gonna use C++ this awesome new functionality called a lambda and in this lambda we need to have our signature of the call back doot-doot-doot which is the entity ID of this thing which will be the entity ID of our ship and the spawn friend we
- 00:03:26
don't need these here this is mostly for other features that people use in this particular instance we need to get the vehicle so from this entity ID you need to get the vehicle so now I'm gonna send ZD we look up the entity grab the vehicle pointer and we access this callback from before that we used all the way up here to initialize the vehicle but instead of we have to capture it so now when we do our lambda we need to copy did you do so these guys are basically our lambda
- 00:04:18
we capture these values we copy them in a sense so that when our spawn entity has finished and these get called we can invoke the callback later that we want so let's magic recode button see how this magical thing works for recode finishes I realized this won't work immediately so this will make this vehicle spawn correctly however it items will still be blocking and that will be a huge problem because now we're spawning something on the backend but we're doing a blocking spawn for all the items on it so we basically won't gain anything so we need to convert our item port system also into this so here's where we do our blocking spawn and it
- 00:05:06
does a bunch of crap what we want to do is turn this into the same framework that let's go back to game rolls haha so here we go we need to get rid of all little sponge because we don't know what we need yet we're gonna spawn our entity it's an asynchronous call we're gonna have our call back right here send in our spawn print send in our spawn params Shazam so here is our spawn entities here's our asynchronous call where we have our entity from in here do close this guy it's him yes all right so we're
- 00:06:03
gonna spawn this entity we're going to and do a bunch of fun stuff when it dips down spawning however we need to capture some of these local variables so some of the things we need is the item port ID we need our entity luckily we have our into the entity ID so we could grab that guy he is finished spawning at this time to get our entity it's kind of a weird thing because it's like hey I'm gonna spawn this guy here's a callback to handle him at a later time so you kind of have to write code saying alright once he's done spawning what would I need to do but push it into
- 00:06:51
something that I might need later and that's what kind of this guy is it's like hey this is gonna happen later so I need to store off all the things I need to do with them hence the capture mechanic we gotta capture this fun little variables see what else do we have params so those are the spawn params haha fun friends are from in this guy we're gonna copy those - where do we go copy all the trams copy more params Shazam we got everything we need so on
- 00:07:44
this guy's spawned we could access all the fun data excellent but there's an item port and we need to keep track of whether or not we want to cancel this so the vehicle spawning we just spawn it into a fire forget this guy we may spawn something but a part two touches before it gets attached so we need to go know so we need at least keep track of this luckily there's already set something up so spawn entity when we want to spawn it you'll actually return this job and access er so we go hey I want to spawn this if something were to happen I could say sometime in the future I want to cancel or abort or even reset it for example right here it's more of a safety
- 00:08:36
code it's like hey I want to spawn this Cup 10 seconds later but in 5 seconds I delete the whole vehicle well that cups gonna spawn and it's gonna try to access all this stuff and go back so this bad boy right here will make sure that if we ever need to do some cleanup for example we're going to delete this item for we cancel any pending jobs so now that our item port is asynchronous our vehicle's asynchronous let's go to our recode fun again Shazaam recode is there now if everything was done right nothing should have changed so we spun our cut list it gets processed and it's now spawned just as before and all the
- 00:09:27
items are on there and everything Shazaam we have framework for any synchronous bonding now there's still a lot of the work to do to move a lot of stuff off the main thread into some background stuff but this is the foundation to get us there hope you guys enjoyed until next time so as you guys saw we had a fun little experiment there where we're trying to build a framework for background asynchronous spawned so we can build something much bigger and yeah start over so as you guys saw we're building a nice nifty framework to process stuff in the background so that your game doesn't get interfered by some guy spawning a Cutlass a few feet behind you or who
- 00:10:18
knows an interest which is a gigantic love practically a level that you fly around in we want to spawn and create everything in the background so it just pops into existence rather than stalling you for ten seconds go moving your mouse going or what's happening but it's gonna take a bit to get there and part of that is building this asynchronous framework you know you build the framework and then you start working a little chunks here and there and then before you know it we have an asynchronous fully systemized system on background threads well hope you guys enjoyed until next time thank you for watching so if you want to keep up with the latest and greatest in star citizen and squadron 42 development please follow us on our social media channels see you soon you
Transcript from YouTube’s automatic captions — punctuation and Star Citizen jargon are approximate. The video itself is hosted by CIG on the official channel.

