Chaos Destruction In Unreal Engine 5 - Part 1: Explosions Using Physics Fields

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey guys i'm john and i'm back to show you a bit more about chaos destruction in unreal engine 5. so i've just opened another first person template project here and i'm going to get started this time by fracturing this piece of mesh over here i'm just going to go to fracture mode go new and select uniform and i'll make this into about 300 pieces and select fracture and i'm going to go back to select mode and just turn off show bone colors all right and what i want to do in this video is show you how to create a physics field that emulates an explosion or a bomb so i'm going to right click here in my content browser make a new blueprint i'm going to go to all classes here and search for a field system actor and i'll call that bom underscore bp and i'll open that up here and the first thing i want to do is define an area for the bomb to encompass so i'm going to make a sphere collision and the default size here is uh 32 radius i'm going to set this to maybe like 200 and i'm going to go to the event graph and i'll create a custom event i'm going to call this explode [Music] and before i make the physics field here i'm just going to quickly add a couple things here i'm going to spawn emitter at location and we'll just use the starter content explosion particle system and i need a location here so i'll say get actor location we'll plug that in and i'll set the scale here a bit bigger maybe three in all the axes and then next thing i'm going to do here is play sound at location we'll use the starter content again the explosion queue and i'll plug in this same actor location okay now i'm ready to create the physics field part so i'm going to drag in the field system component here and i'll drag off of that and say add transient field okay and for this i'm going to say enable field and set the physics type to external strain and now i have to define the field and it's not as easy as just plugging in say the extents of our sphere collision we have to first make a field out of that and so i'm going to add another component here called a radial falloff and we'll set up the easiest kind of field here first the radial falloff i can drag into the graph here drag off of that and say set radial falloff and get this field function here and i can define here magnitude and range and the radius and position for this field so i'll start here with the uh radius and position so what i'll do is drag in my sphere for my sphere collision for the radius i'll drag off that and say scaled sphere radius and the for the position i'm just going to drag off the sphere here and say world location okay and the magnitude what i want to define as a magnitude for my external strain i'll just go over that quick here we'll go back to the map and select my fractured mesh here and in the details here if we go under clustering and we have a damage threshold here so by default these uh damage threshold is set to these three values these three indexes here 500 000 50 000 5000 and what that's defining is the amount of strain that will be required to break this mesh at the different fracture levels and so i only fractured this mesh one time and so the only uh figure that's going to apply here is this index 0 500 000. these other two indexes aren't going to be used because there are no other fractured levels but if they're if there was those would be the strain thresholds to break into the next level of the smaller piece so for this case uh what i want to do is break everything apart for sure so i want to set a really big number like 500 000 or more so i'm going to go back here and 500 000 will be fine uh okay and the last thing we'll look at here is the falloff type so i'm going to select none for this one so it's going to fill this entire sphere with the full amount of this magnitude but you could define a fall off say like linear for example and now the magnitude would only be 500 000 right at the center of the sphere and it would fall off towards zero as you move toward the edge of the sphere so for different fields different kinds of effects you could use something like that but in this case i don't need that i'm going to fill the whole sphere with the full magnitude of 500 000. okay so i can take this return value and plug it into the field node and that part is basically done the next thing i'm going to do here is just make a quick and dirty way to explode my bomb in the map so i'm going to go back to the first person map drag my bomb blueprint into the map here and we'll put it say by the corner of this destructible mesh and now i'm just going to go to my level blueprint and i can drag in this reference of the bomb from my world outliner and just drop it into my first person map level blueprint and now i'm just going to drag off this and say explode and to cause that to happen i'm just going to right click and say f key and we'll use the f keyboard event and plug that in all right so let's try it out here i'll press f all right so we have our explosion happen but it's just causing the strain so far so i can press f again here we're not we didn't destroy the actor or anything and we can see we've caused this strain and this breakage to happen but um not really like an explosion yet nothing really went flying there's no real forces happening and so that's the next thing that we're going to set up here i'll go back to the bom blueprint and what i need to do is add another transient field here so i'm going to grab from my same field system component here drag off of that and say add transient field and for this one i'll select enable field and the physics type will be linear velocity okay so i need to define uh the field node again and for this one i can't just plug in the same field here the radial falloff i need to define a slightly different type of field and so i need here to add another component a radial vector okay and i'm going to drag my radial vector into the graph here i'll drag off of that and say set radial vector and for this one here it's basically going to create a field of this magnitude that emanates from this center position outwards radially uh covering basically the entire world this field doesn't define any extent or end limits so let's say i put in a magnitude here of 1000 and for the position for this i want to use the same center position as my sphere here so i'm just going to borrow this uh world location here and plug that in for the center position all right so let's say i plug this in just as it is uh to this linear velocity field uh i'll show you what's happening here okay i'll press f to explode now we get some velocity there now let's press f again and again and again okay and if i keep pressing it we can see these blocks that aren't even near the explosion are continually receiving velocity every time i press f here i'm pressing it a bit quicker now and i can send these blocks flying it doesn't make any sense why that would be happening when the explosion's over here and so what's happening is the radial vector field like i said it has no end limit or extent defined so it's happening throughout the entire world and so for this kind of field we need to introduce one more thing here and that is a culling field so i'm going to add another component here a culling field and i'll drag that onto the graph here and same thing here i'm going to set culling field and for this one we want to use this radial vector as our input to this field so that's where we're starting and for this i'm just going to unhook that the return value of our culling field is now what we're going to feed into our linear velocity and we need to define what we're calling it how we're calling this so the input is the radial vector that emanates outward and we're going to cull it by some amount beyond that and so conveniently i already have defined this radial falloff here which covers the area of our sphere so i can actually use that return value as our culling field so we're going to stop this radial vector at the outer edges of our sphere and in order to actually do that i have to select outside rather than inside otherwise we would be doing the reverse operation and so that can be useful for other types of fields that you might need to create but for this one we need to call everything outside of this radial fall-off so that we aren't getting this linear velocity impacting anything except for what's inside this sphere okay hopefully that makes sense and i'll show you the final effect here so i'll press f we get our explosion uh we can if i press f again the only piece is being affected our piece is actually inside the sphere now we can see uh nothing is moving toward the edges of the map here we're not getting pieces that are flying all the way outside of the the map right so that's pretty much it that's how you define a explosion style physics field and uh in the next video i'm going to show you how to use an anchor field so that we can uh create some other cool effects like blowing up the walls here and saving the floor okay thanks for watching and i hope you enjoyed we'll see in the next video
Info
Channel: BuildGamesWithJon
Views: 34,969
Rating: undefined out of 5
Keywords:
Id: i5f1DevgDUs
Channel Id: undefined
Length: 12min 14sec (734 seconds)
Published: Tue Mar 08 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.