Unreal Engine 4 - Chaos Destruction Basics

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello guys smart Paula here welcome back to another video so today I will be teaching you guys the basics of using the new chaos destruction in on the engine for chaos is epic games new fully dynamic destruction system currently in beta and only available via a source build of Unreal Engine if you haven't already watched my getting started with chaos video go ahead and check it out you're going to need a source build of the engine with chaos enable so just go ahead and check out that video if you haven't already alright so first up what we're gonna go ahead and do is create a brand new project so just launch whatever version you want I'm going to be using 4.25 I'm just going to create a first-person shooter game and I'm not gonna include any starter content and I will just name this chaos basics and then we'll just create the project sort of get chaos enabled in this project all we have to go ahead and do is go to our content browser first we have to create a new C++ class if we haven't already converted this project to C++ so that we can compile it and have the Visual Studio files just right-click anywhere click new C++ class create a blank class it's going to open up visual studio once it loads up you can go ahead and close it and then you can go ahead and close your project then what you have to do is go to your project folder this is where ever your unreal projects are installed on your hard drive you can find this by going to your library chaos basics right click show in folder and it will open the folder on your drive gonna want to make sure you have the dot SL and Visual Studio project file which is again what we just created by adding a C++ class then going to your source chaos basics editor target ICS right click edit that you're going to add two lines be compiled chaos equals true be use chaos equals true file save that then we can go ahead and switch unreal engine version to use the source build our C Drive which I showed you guys how to do in the getting started with chaos the structured video so again if you haven't watch that to make sure you go ahead and watch that first and just go ahead and click OK it's going to generate the Visual Studio project files and then you can right-click the SLM and open up with Visual Studio 2017 and it should have Unreal Engine right here the source build as well as your project chaos basics make sure this is development editor 164 right click on your project and click build so this may take a couple minutes for it to build but just let it go ahead and run once it's finished building here you'll see build one succeeded you can go ahead right-click your project and click debug start new instance and this will just go ahead and launch your project here and once you've basically built your project and dumbness you can now just launch your project from the launcher here so if you want to start up your project again you don't have to rebuild your project you can just launch it from here so you go to edit plugins I'm going to search chaos and you see all of the chaos plugins are enabled and there's one more plug-in that we actually need to enable that doesn't get enabled by default and it's actually really important and it is the field system plugin so just make sure you click enable it's going to tell you to rebuild but it doesn't really matter you don't have to do this just click yes and restart the project alright once you restart it research the field you know see it's enabled again so now we can go ahead and start working with chaos and the engine so first of all let's go ahead and import some geometry that we can use to fracture and to play around with so I have included this pillar that wouldn't go ahead and use for our project files link will be in the description down below to use it just go ahead and drag the FBX file import that and then for the textures drag these two textures in open up the material and drag those in and connect them up okay and then we can go ahead and drag our mesh or geometry right into the scene and you're going to see here it's this pillar I'm actually going to make a few adjustments to our scene and you'll see why I did this in a second it's going to select everything and move it down so that it's flush with the grid and I'm doing this by holding down the shift and then we can also go ahead and drag this out of the way and we can go ahead and set our lighting sources to moveable we can go ahead and delete the reflection capsule so go ahead and select your column right here go to the modes the fracture mode and this is essentially chaos and is very basic functionality you can fracture your mesh in two different pieces that way we can destroy it in-game and to do that you're going to create a new geometry collection a geometry collection is basically a collection of all these individual fractures of a mesh you can have more than one mesh in a geometry collection you can select multiple items and we'll add it to a geometry collection or you can have multiple meshes in a blueprint and create that as a geometry collection so let's go ahead and in this pillar and create it so we have different options to fracture our geometry we have uniform clustered radial planar slice brick we're just going to do the uniform we're going to go ahead and scale our fracture up to say 200 click fracture as you can see here it's fractured our mesh if we drag this explode right here I'm going to see all the different pieces that it created all the pieces that will basically break apart and on the left side here you can see all the pieces right here down in the bottom you can see the level statistics so you can see at level zero there's one geometry which is the brute and that level one we have a hundred and ninety four fractures to switch between your levels we can go right here and go to level zero level one okay so right now we were to simulate it I'd be a lot of rigid body simulating at once and you don't really want this many all at once so we're gonna go ahead and basically cluster these into larger pieces before you actually simulate or do anything you'll obviously want to save it for point two five version of chaos is actually pretty it's not the most stable build it's just to be expected when you're when you're messing around with the experimental things so what we can go ahead and do is start clustering our mesh to do that we go to the cluster tab going to select all click the hanno cluster this will bring up our cluster settings and the cluster sizes is basically gonna determine how many pieces do we want for our level so if you remember at the start we had 194 so if we auto cluster we can bring that down to say a hundred so half of what it was and click auto cluster you can see it's created a new level level one and it's moved our previous level down to level two and you can see here we have much larger pieces and much larger chunks so we can go ahead and do this again a few more times select all auto cluster we're gonna do half of 150 it's going to create another new level and you see the pieces are getting larger so basically what this is doing it is allowing us to bring our geometry down to a more manageable amount of rigid bodies that we're going to simulate that way you know we're not simulating 100 200 or 300 rigid bodies all once so I'm just going to do this one more time and bring this 8 down to 10 and so as you can see here we have all our different levels of a 1 2 3 4 & 5 and basically what this is is an LOD system for destructible meshes and so you can switch through your levels by changing different levels right here or you can use the shortcut shift W you can also explode the mesh here to see all the sizes of the clusters that we created all right and if you move this tab up over here you can see in our chaos physics we're going to have some options here some parameters and under this clustering tab going to see is damage - hold the damage threshold directly core responds with your levels here so level zero as I will zero right there you can add more damage there holds for each corresponding level so maybe we'll set this up to like five thousand four thousand three thousand and so on so it's going to take less damage to break up the smaller pieces but more damage to break up the larger chunks so if you move it up a little bit and then hit play I'm gonna see it automatically breaks up so we can go ahead and change our damage threshold here ought to be a little bit stronger so let's go ahead and up this to say it like thirty thousand four five thousand five thousand okay and then we can also go to our geometry collection that we created so if we right-click here browse to asset and click on the pillar we're going to have this little options menu right here so if we expand our collection our collisions right here you're going to first see obviously the materials but we're more interested here in our settings I want to change the implicit type to level set this will basically make it have to load the geometry every time we open the project or every time you have a load in your disk we're also going to set masses density and give it a mass of say two thousand go ahead and hit save for that and so if we hit play you're gonna see it just crumbles like that so you can go ahead and play around with these damage thresholds but that's pretty much the basics of that now we're gonna go ahead and talk about fields and the different various fields that there aren't chaos fields are components that basically allow us to do many different things with in chaos itself to have fields you want to make sure you can enable the field system plug-in for chaos but basically allows you to create a field so you right click in your folder go to physics and create a field system we can name this anchor field and then if you try to click on it's not going to open up or anything so we're going to go ahead and do is she dragged this into our scene and then right here blueprint ad /script we can go ahead and click that because right now it's doing absolutely nothing so let's go ahead and add some functionality to it through blueprint go ahead and just leave it as it is anchor feel the blueprints and select that okay and it will open up our blueprint here basically we're going to go ahead and go into the construction script we're going to add some components here on the field system component gonna add a cube since this is an anchor we're going to add box fall-off colon field and uniform integer and then we're going to get our field system components and add field command and hook this up there are different fields right here you can see we have dynamic state which is basically you go into the general tab right here you can see it's simulating as dynamic we have sleeping kinematic static dynamic and user-defined so that directly corresponds with some of these as well so basically a strain can be defined as either a cube or spear or a region of space and you can tell that region of space to either simulate to be dynamic or to be static or to apply some sort of explosion or some sort of force to a certain region that's pretty much the basics of fields and if you want to read about the different types of fields you can go ahead and head over to the chaos destruction documentation under the field type you'll get a description of each field here the one that we are creating currently is called an anchor field which is right down here and basically an anchor field is made up of a few components that tell a certain region of area to be static while the rest can actually simulate so we can go ahead and do is grab a culling field set calling field hook that up to the field right here and then we'll go ahead and get the Box fall-off box fall off that up into the calling for the transform this is going to define what region of space we want to maintain a static rather than dynamic simulation we're going to get our cube that we have in our scene get world transformation and hook that up for the transform for our field here we need to get our uniform integer set uniform integer hook this up into our field we're going to create a new variable it's going to be of the e object state type this is basically enumeration we're gonna name this to static state so we hit compile you're going to see under the default value there are different settings here we can choose we're going to go ahead and click the static you can go ahead drag that variable into our blueprint I'm going to go ahead and drag this off and go to int and come word that to integer and then you're going to make sure you set the Kohen field right here it's very important set this to outside now we also need to change this to dynamic state as well so it adds a dynamic state everywhere outside of this field other than this box so everything outside of this box is set to dynamic except for this box itself this is set to static so this is basically an anchor this will allow us to anchor our geometry by overlapping it so this is our anchor field blueprint and so if we merge this into here and actually scale this up and move it something like that so right now it's intersecting so it's going to tell these pieces of geometry to be static while the rest can be dynamic and before we hit play we actually need to set this up so if you click on the geometry you're going to see initialization fields it's an array so you can add an element and once you add it you can choose the anchor field or you can actually hit this little sample tool and click on that little box ok so if we hit play now you're going to see it's not gonna fall to the ground and and if we actually go ahead and rotate this you're gonna see it's also not going to fall to the ground but this is still dynamic so technically we can still destroy it so yeah that's pretty much a an anchor field and now there are various other fields what we just saw on what we just created which is the anchor fields they hold pieces of geometry together we have cluster strain fields a force field so as you can see it blows it up then we have fall-off an angler torque Nori's slash cooling sleep slash disabled so as you can see here it freezes the simulation and it disables the simulation and then we have internal strain which applies a little bit of strain internally and you see the building just falls apart like that okay so there are various different fields here and this is actually the chaos destruction demo but right now it actually only works with 4.23 like I said I've tried compiling it with 4.25 it just doesn't work well I'll probably actually go ahead and do is migrate some of these blueprints out into a 4.25 project for you guys to play around with but of course if you guys always want you can always compile a 4.23 source build and open up the chaos destruction demo and see all the different examples here so what we're gonna go ahead and do is we're going to go ahead and modify our first-person gun right here so we can actually go ahead and blow up or shoot off some of these some of the pieces here on this mesh so we're gonna go ahead and go to our first person BP blueprints and we're gonna go ahead and right-click and create a new field system weapon compact okay go ahead and drag us into the scene and add a blueprint script and then drag that to the top and you can actually go ahead and delete this so in our blueprint here off of our field the system component we're going to add a beer collision and then on a first spear collision we're gonna add ace spear in our event graph off of the event begin play going to do a sequence then what we're going to do is add some components here we're going to need a radial force I need a operator field radio fall-off and actually make sure it's out here not on these so go back here to radial vector random vector uniform vector and operator field then we're going to get our field system components apply physics field hook that up there I'm going to enable it going to get our radio follow and set radio fall-off hook that up into our field for our magnitude we're going to promote this to a variable name this strain bag to the pilot you would have a default value of like 10,000 now the radius will multiply float by float gonna add 250 on the bottom right here we're going to get the spear collision get world scale and split struck pin going to get the X and multiply that by 50 we're also going to get to world location and knock that into our position I'm gonna leave the fall-off as none I'm just gonna go ahead and clean this all up then want to get our fields to same component and apply physics field oh and then we also want to changes to external cluster strain apply physics field make sure that's enabled going to change this to linear velocity and then we're gonna go ahead and give us some space get the operator field set operator field hook that up into the field I'm going to get our radial vector set radial vector the magnitude pull it off MOTU variable name that force magnitude off the position get or location of our field system component I'm gonna hook that up into the rights field and I ask for the left field we're going to get the radial fall off set radio fall off I'm gonna hook that up to our left field here and we can actually go ahead and just copy what we did over here and paste it for our left field I can change that fall off right here to linear and then want to change this from multiply to add should be all good there finally we're going to apply another physics field this last one is going to be angular torque go ahead and set the operating field again and then we're going to get the random vector set random vector change the magnitude to you something like 3000 hook that up into our right field for our left field look at the uniform vector set uniform vector that up to the left field and change the Z to 10 and the x2 for changes to multiply then we'll hit compile and save that add a sequence of our second sequence here add a delay and then destroy the actor okay so I had to play around with our weapon impact blueprint here I made a couple changes using the same field system component for each of these apply physics fields as well as I thought the world location from that same field system component and then I apply the physics field and as well as here I have a mohawked up to this one fields this component I also changed this to you multiply right here for they set operator field I never lost the angler toric all that I adjusted my strain magnitude to 50,000 my force magnitude to 5,000 in my view ports I adjusted the size of my spear collision 250 and yeah that's pretty much all of the changes that I did here again you can just look at all the different changes I did here so if we go ahead and go to our first person projectile off of our event hit we're going to spawn after from the class going to select our weapon impact blueprint and then our hit location hook that up to the spawn transform and then after that we can destroy actor you hit play now when you shoot the ball and it breaks the columns like that shoot the pieces and you can also adjust the weapon impact the strain and force magnitude but if you select the geometry as well you can also adjust the damage threshold here which I did player on with so we can go ahead and actually bring this down a little bit so you can see parts of it are flying off like that and what we can also do is go ahead and rotate this back like so actually while I'm gonna go ahead and do is make this anchor field transparent so if we go into our viewports here and change this material out to few options use engine content show engine content right here you can search your simple translucent and use that material to represent our anchor so that we can actually get a better visualization of everything so now we can actually go ahead and start creating like say if we want to make a pillar here or call I can go ahead and select both our anchor and our column and alt click to duplicate and drag it and then here we have to set up our anchor remember so select your geometry select the anchor right here we can take this piece of geometry and move it up change your grid snapping to 50 then alter track these up should snap just like that okay we can rotate it here and move it just like that if we were to hit play everything or just crumble right here this top part basically we're going to build a connection between these pieces here and to do that what you're gonna do is we're actually gonna go ahead and move this a little bit closer and we're going to select all these geometry pieces and change the cluster group index to like three so basically this tells which index is a part of so all of the assets are in the group cluster index of three will be part of the same geometry or the same like building structure so if I hit play nothing's gonna fall down and you see that top part doesn't have any anchors because it's connected to these pillars right here so if we go ahead and shatter part of that you're gonna see it crumbles like that and let's go ahead and actually adjust the damage threshold because we don't want breaking apart so easily tweak these up a little bit actually - well just select all these and change the values so let's up this up to like 20 thousand seven thousand and so we can actually go ahead and duplicate this geometry snap them together just like so make sure the group index is 3 as well and then make sure this is actually anchored to that proper anchor so for hit play we can start breaking some of the pieces here as you see our frame rate is dropping because we need to adjust the damage threshold of some of these items here really just gotta mess around with the values and find which values work for you now obviously if you have a lot of rigid bodies and if you're having just a lot of destruction going on you're going to want to have what is called a sleep field which I haven't covered in this video but basically just like the anchor field you'd set it to sleep or to kill and it basically stopped the simulation of these rigid bodies so as you can see they're kind of glitching on the floor right now because they're still simulating and it's still costing us our memory so if you add a sleep fields on the bottom it's going to catch the pieces and stop them from simulating so just helps out with optimization so anyways guys I hope this was a good Kaos basics tutorial again I'll have to make some more tutorials on some of the other fields as well as some of the other features that Kaos has maybe will go ahead and you know make a building out of these destructible assets so that'll be really exciting to do so anyways guys if you liked this video make sure you hit the like button and I'll see you guys in the next one
Info
Channel: Smart Poly
Views: 91,181
Rating: undefined out of 5
Keywords:
Id: VWzCMGcC6eA
Channel Id: undefined
Length: 27min 26sec (1646 seconds)
Published: Fri Jul 17 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.