Blender to Unreal: Custom Collision for UE5 (E02)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello and uh welcome back for another video in the series i'm trying to be quiet because it's it's pretty early here um but we're going to talk about complex collision and simple collision today and how to do it properly because i see a lot of videos that say you know you're having issues with collision on an object and you want to get your collision to work just uh so just go into the project or the settings for the the static mesh and turn on complex collisions and uh don't do that that's a bad idea and we're going to talk about why that's the case and how to do it properly so i'm opening up unreal engine 5 and this is the same for unreal engine 4. the collision really hasn't changed and i don't expect it to uh when in real five comes to full release and i've got blender open in the background and we're gonna take a look at some object collisions and then how to actually create them right so uh if we're good to go and have a look at an object i'm gonna grab it just a random decorative object and look at it here uh let's see we've got for example this bonfire here if i grab this bonfire up here in the top and it is under the show tab you can turn on these settings to show simple collision and show complex collision so this is the simple collision mesh for this object and if you are using the default settings for importing your static meshes into unreal engine then what will happen is it will auto generate a collision mesh for you so you don't necessarily have to make one and sometimes this is fine so there are a lot of objects like for example this crate here if i show the simple collision on this object it's a box it's it's not a super complex object and so you can use the auto generated collision for this object and it's not going to be a problem and for any objects like this that are convex and fairly simple in shape that's totally fine you can use the auto-generated collision when people run into problems is when they start to use concave objects like doorways for example if you're creating a doorway if you're creating uh maybe a bridge that has a railing and there's like a gap in the middle for you to walk through that's a concave object and the reason that it's a problem is because simple collision can't do concave shapes and so how do you fix this well the suggestion that i've seen from a lot of people is just to enable complex collision and what that does if i go through here and i hit show let's turn off simple collision and turn on complex uh is it's essentially using the static mesh of the object you can see the complex collide in here complex collision mesh here is essentially just a duplicate of the object's static mesh itself the reason that that's a problem is because now you're rendering every not rendering but you are you are utilizing uh the poly's for uh all the polys in your objects twice essentially right so you're loading the whole static mesh twice so you're essentially doubling the load on your processing system by using complex collision and sometimes the complex collision doesn't necessarily do it correctly anyways if you have um i've had a couple of times where i've used complex collision when i was learning how to do this and found for example that it didn't draw it perfectly around the object for whatever reason i don't know i don't know why um but you don't really want to do this and it's because you know there's a much more efficient way of doing this if you think for example you have a complex looking doorway where you have you know a door handle and you have you know all sorts of different panels on the doors and a door frame do you want complex collision turned on for that no because you don't necessarily need you know to be utilizing the 200 polys in your uh you know your door handle and your door frame again just for the sake of collision you could get away with like 12 polys by using a proxy mesh so that's what we're going to set up i'm going to show you how to do that and what that will do is essentially create a simple collision mesh that is just using simple collisions so there's no there's no you know complex shape to it as your as your collision mesh now in order to do that you need to turn off uh the auto generation of collision meshes in unreal engine on import so on this object here if you go down to your import settings and when you go to import your meshes if you uh drag and drop your meshes into like from your file explorer into your your content content folder what's going to happen is you're going to get a pop-up window with a whole bunch of options of like how do you want to import this object it will be in there also so you don't have to do this you don't have to do this in this window you can do it when you're importing your mesh and what you want to do is down here in your import settings under generate missing collision you want to tick that off then when you import your object uh it won't generate any collision meshes and so it'll it'll only use the custom collision that you are importing so turn that off so that it doesn't generate any collision and then we're also also going to search in the settings for customized collision and you want to turn that on and so you're going to use the custom collision that you're importing along with your mesh and i'm going to show you how to set that up in blender and then import it here so that it works correctly so let's go ahead and move over to blender and i will show you how to get this set up so we're gonna go in here i have my fancy new default crab you can change your default object when you load into blender by the way just by overwriting the the default load file which you do in file default save startup file and it'll overwrite your existing startup file and then i'm going to create a object and i'm just going to create something like super simple just like for the for the purposes of demonstration here because we don't need something that is super complicated now this is an example of an object that will not work with simple collision because it is uh concave so it's got this hole in the in the middle so this would be for example like a bridge um and actually let's let's make a bridge let's make it a little bit a little bit longer and that'll be fine for this so if you tried to generate simple collision from this automatically what it would do is it would just draw a box shape around this because it can't do the it can't do the concave parts of the mesh and so you would either have to use complex collision or you would have to use a custom collision which is what we're going to do i'm actually going to make a slightly more complicated bridge just because i want to sort of demonstrate the reasons why you would maybe not want to use complex collision for this and how you can do it with with custom collision instead all right so now you can see that we have this object here which we want to have collision on and this is still if you were to generate simple collision around this it is still just going to draw a box around it because it can't do the concave portions of this and this as you can see is a reasonably dense object it's not super dense but it's 2 000 verts which is you know a decent amount but if you were to use complex collision for this it would essentially double the number of verts that are being called for this object right so instead of 2000 it would be 4000 and so by turning on complex collisions you're going to be doing that essentially for every object that you have it enabled for so let's make a proxy mesh for this object that is very low poly that we can use as our collision mesh so all i'm going to do is i'm going to name this and this is actually an important part of the process you want to give this you want to give this a name which is fairly specific i'm just going to call this bridge and there is a reason for that which we're going to come back to in a second and then we're going to create our collision mesh as a separate object so for the bottom here i'm just going to uh see here i'm just gonna draw a new one and one thing that i like to do when i'm creating collision meshes is just give them a different color uh you can do that by adding a material it doesn't matter it's not going to save this save this information but just so that you can tell where you've made collision and where you haven't it's not a big deal on something simple like this but if you're making something complex say you're making like a house that has you know doors and stairways and a whole bunch of other other stuff in it then you you want to be able to tell where you've made collision and where you haven't all right so this is our collision mesh so everything that's in green is going to be our collision and the reason i've made it out of separate parts is because of course simple collision can't do you know concave shapes but it can do convex shapes and you can have multiple of them so this collision setup for this is going to be made up of three different shapes and this is how you get the concave shape using simple collision only and this will work for doorways this will work for bridges it'll work for pretty much anything now in order to get this into unreal engine you need to tell the software which parts of this mesh are actually static mesh and which parts of it are only going to be used for collision and that's pretty simple to do the way that you do it is with the naming convention and the reason that i said that we should have a very specific name for our object is because if you have lots of objects in your scene sometimes you you want to make sure that you are having separate names for each object object which are unique identifiers because you have to use the specific and exact name for the collision boxes so if i were to use css bridge if i were to use you know bridge underscore one or bridge with a capital b instead of a lowercase b then your collision won't work it has to be exact so the way that you do this is you go ucx underscore and then the name of your object i usually just copy and paste it so that i know that it's going to be exact and then underscore zero one and you can add as many numbers to the end of this as you want and it will load so you can have multiple different collision boxes so i'm going to do that for these other cubes so this will be o2 and this one will be o3 and the names are exact so it has to be exact so if this is bridge then this has to be ucx underscore bridge and then the number and that's really all you have to do in order to get your collision set up so let's go ahead and export this as an fbx and then we'll import it into into unreal engine and so the way that you would do that is to select everything because you want to make sure uh i mean different people have different export settings for their static meshes but when i'm exporting fbx i usually have this selected objects only turned on so you want to make sure that you are definitely exporting your static mesh and also the other components with it so all of these will be in one in one fbx file essentially i'm just going to save this on the desktop and call it a collision example all right so now back in the engine we're going to import this and to do that i'm just gonna open the content creator and drag this in and let's have a look now at the settings so on our import settings the one thing that we need to make sure of is here where it says generate missing collision that that's turned off and it's because we're importing our own collision we don't want it to generate anything i'm also going to tell him not to create materials because this object doesn't need any materials so you can see that it imported our static mesh and the collision meshes that we added to this are not visible here so they're not part of the object you can see if you look at this here that we don't see those we don't see those objects anywhere and it's because they were converted to collision so if i go up here to show simple collision you can see that it is using that collision mesh that we created as the collision mesh for this object and down here in your collision settings under collision complexity it'll say you have a couple of different options here some people say use complex as simple don't do that we're going to use simple collision as complex or leave it at project default use simple collision as complex is fine because then what it's going to do is it's just going to use the simple collision mesh which we just created as complex collision as well and we have customized collision enabled so now if i go ahead and bring this into the into the world uh let's take our little bridge here and it looks a little bit large maybe i'll just shrink it a little bit you can see that we can now walk through it even though it is concave and our collision is working on all on all sides where it where it should be so we've managed to make our collision for our scene and we have significantly reduced the complexity of the geometry that's in our scene when you think about how poly density objects in the original collision mesh would have been if we were to use a complex complex collision the the mesh that it would use uh is over 2 000 polys so that's a you know a decently poly dense mesh but we've reduced that down to 24 polys so from over 2 000 polys down to 24 is a pretty significant reduction in the complexity of the geomet geometry that's going to be in your scene and so whenever i'm whenever i'm creating objects for for the world this is essentially how i would do it this is just uh good to it's good to get this to be sort of part of your habit of creating assets for for the world so that you know that your collision is going to work correctly on everything that you create so that's it for uh for this this video so until next time [Music]
Info
Channel: CG Krab
Views: 13,363
Rating: undefined out of 5
Keywords: cg, krab, unity, unreal, engine, unreal 5 beta, blender, tutorial, guide, how to, game, asset, ue5, modeling, sculpt, beginners, low poly, course, free, character, vfx, fbx
Id: BIPe8SBKyUs
Channel Id: undefined
Length: 16min 23sec (983 seconds)
Published: Sun Jan 16 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.