Join Craig Barr for an in-depth discussion in this video Adding and editing collisions, part of Unreal: Architectural & Industrial Visualization.
- [Instructor] In order to add believability or more interactivity to our visualization project, we want to add collisions to the scene. Now we saw how on the floor we used auto generated collisions, which is fine for the purposes of the floor, but the rest of the objects we turn that off because we want to be able to customize with collisions. It's important to note that if you put a collision on everything, it'll really bog down the memory on the game. So you want to be efficient with them. And that's what we're going to take a look at how we can do that.
Now if you're following along with the exercise files, you'll see that I'm using Chapter 05-02. And if when you open up the file you're not able to see everything that I'm seeing here because of all the other components in the way, I've gone ahead and created a directory for you so that you can have everything hidden. You can just simply hit the eyeball on there, the icon, and have that turned off. Now if you want to be able to create one on your own, I simply just selected the components within my Outliner here and then, with each component selected, I went to Create a new folder containing the current actor selection.
You can actually even just create a folder and then grab other pieces and then simply right-click and go down to Move To and have it move to another directory within your Outliner. So it's a handy thing for keeping things organized, and simply a quick way to be able to turn visibility on and off for objects if it's in the way while you're working. So let's take a look at how we can work with collisions back into our Static Mesh Editor. So we saw the editor before and now we want to be able to actually work with this a little bit closely here.
So I'm just going to zoom into the kitchen space and we can see that we have all of these different objects but none of the them have collisions on it. And probably the best way to experience that is simply to play the game. So let's hit Play, and drop down, and we'll just click in the Viewport and now if you're using a game pad controller you can simply use this to manipulate your way around but if you're not, and you're using the keyboard, you'll use W for Forward, S for Backward, A to go to the Left and D to the Right. And our mouse is driving the direction that's we're looking in to walk in.
So we can see now that the environment is here but if I walk into any of these things, I'm walking right through them because there are no collisions set. So we want to see how we can work with these collisions. So let's hit Escape, let's go to this kitchen island and we'll zoom in. Now we'll see that if I have these countertops selected and if I want to work with collisions, a problem's going to be there that I'm going to either have collision defining this entire area around here and we won't be able to walk into the kitchen, or I'm going to have to customize and build one for this and another one for that.
And then I have to worry about the rest of these components. A better way is to be more efficient with your collisions. And that is using one object to encompass it. We're going to work with this Kit_set_kit_island and I'm just going to either double-click on the asset or just go to the Static Mesh icon there and bring in just that component into our Mesh Editor here. So if we turn on collisions we'll see that we actually don't have anything on that object so let's go up to Collision on the top menu here up on the left, and go to Add Box Simplified Collision.
And you'll see what that's going to do from the pop-up bubble. It's going to generate a box collision mesh to encompass the entire static mesh. And there we have it. This is an easy rectangular shape so it very easily encompasses this. But now we can edit this. And we can simply do this by clicking on that collision and using the W, E or R hotkeys. Now if you have Snap on, let's say for example the Snap is turned on here, let's turn on Snap on all of these things. You're going to get Snapping to whatever you might have it set to.
I'm going to keep Snap off for this, because I don't need to have it Snap out into a giant area, I just want to be able to bring this out, maybe a little bit wider, and I do know that I have a dishwasher and different appliances over there, so I don't need it to come up that far, but I want it to encompass those stools that I know are over there. And let's just bring this scale up by hitting R, and just bring this up a little bit higher. It can go even above the countertop if we want, we're not going to be touching on top of that countertop anyways, but that simply should encompass just about everything now on that kitchen island so that we're not able to walk through it.
So that's that. We've put a simple box on there, we've hit the R hotkey, scaled it, W to move it around, and we could even rotate it if we really wanted to. We don't need to in this case. So with that done, let's go up and hit Save. So that's going to save that asset with its collision on there now, and what we can do is, let's go back and test this. So let's go back in the environment, click in the Viewport, and you can see we're walking through everything else, but now we're stopping on this asset. We're not able to walk through that asset.
So I can tell by the way I'm walking with this here that I'm actually bumping into this by quite a bit. So we could edit this a little more but there are other things that we need to consider. And that is actually the character scale. We'll get to that a little bit later. But for now there's how we can simply work with collisions efficiently. I'll just hit Escape to get out. So rather than putting collisions on all of these different things, we've just put the collision on this simple little kitchen island in here so that we're able to encompass all of these different components with one object rather than many.
And we'll go ahead and continue to do that throughout the scene. Now for things like the walls, let's go up and actually turn the walls on from our Building_components folder here we'll put walls on. This is a little more tricky. This is a little more complex because I've brought the walls in as one and I purposely did that for the purpose of illustration here. If we auto-generate collisions on that, it's going to be quite heavy. But we don't need collisions really everywhere and that accurate on this. We can simply go in and begin to build collisions in and around certain areas.
Now I'm not going to build every piece of collision in here but let's jump into that and actually start to add collisions into this section of walls that we have here. Now how can we do that? Well, the exact same way that we just worked with this here. So, with the Mesh in here, we'll go to Collision and we'll Add Box Simplified Collision. Now it's going to want to put it over top of the entire mesh. We don't want that. We want to be able to start to scale down and be able to place collisions only where we truly are going to need them.
Now we're going to need them on the walls, so for example here, I'm going to take this collision box here, and just drag it along and bring it to this wall, we should make it a little bit bigger so it encompasses all of that, and we'll just drag this around. It's okay to have it overlap, in fact, it's probably better to do that so that you're not walking through the corners. And one thing to note, you can see that I'm going beyond this area here, and that's simply because there is that stone wall fireplace there.
So we might as well just block this off so that we're providing a collision on there as well. Now most of the kitchen is going to provide the collision that we're going to need over here, so we're not going to need to worry about that. But this outside wall, we will need to worry about. Now we have a couple of different things that we can do with this. With that box selected there, we can go Collision, Duplicate Selected Collision, and now I'm going to hit E for Rotate, and I'll just bring this around and this is actually where I should ideally use my- let's rotate this by 90, so that we're using our Snap, and there we go.
By Snapping that into place, then I'll hit W and that has let us Snap that into 90 so that we can just really quickly bring that in, and we'll hit the R key and just scale that down a bit. I'm just going to bring it over top of the edge of that window. So now we continue on and do the rest of this in here. As I said, we don't really need to do every wall. The kitchen counters are going to take care of most of this part over here, so we'd probably want to build another collision here, and we'd want to continue on and actually have the front entrance collisions and, of course, these walls in here as well.
The bathroom we can get away with a simple little collision here. The shower will have its own collision. And of course the cabinets in the kitchen are going to take care of the collision on that wall itself. So we don't need to go crazy and add collisions everywhere. You really need to kind of plan it out and think about objects that are there that can provide the collision overall for you. So that's a basic overview of how we can add and edit collisions within Unreal Engine for our visualization project.
- Defining project goals
- Creating an Unreal Engine 4 (UE4) project
- Adjusting first-person project settings
- Creating effective assets
- Exporting assets for UE4
- Importing assets into UE4
- Placing assets in a scene
- Adding and editing collisions
- Working with textures
- Creating a basic material
- Adding a post-process volume