Setting collision in the Static Mesh Editor
When you convert BSP to a StaticMesh, and when you import a new model from an external source, the mesh will have no collision calculated. UDK provides an easy way to automatically generate collision geometry for imported StaticMesh assets. Collision geometry can be calculated from the actual mesh, but that is seldom efficient. It is better to use a proxy mesh with far fewer polygons, encasing the visible model. Instead of bumping into the visible model while playing, you'd instead be bumping into the low res collision model linked to it. Without collision you'd run right through the model, though that may be desirable for some models, such as grass, flowers, the canopies of trees, and things that would otherwise be troublesome to snag against when moving.
How to do it...
- For the base meshes that come with UDK, it isn't a good idea to try changing them. However, you can Create a Copy and edit that instead.
- In a new scene, open the Content Browser, click All Assets, then filter Static Meshes. Type Mesa in the search field. This model is a rock without collision.
- Right-click on the mesh and choose Create a Copy... to duplicate it into a package of your own.
- Double-click on the resulting copy and the Static Mesh Editor will open.
- The fifth icon along [ ] toggles the collision preview. At present, there is no collision so toggling it won't make any difference yet.
- Above, in the menu, under Collision, choose 6DOP simplified collision. This will create a box collision only. It should show up as a wireframe around the object and you will see that there is a lot of negative space within the collision box.
- In the same menu, try using Auto Convex collision using the settings shown in the next screenshot, which accumulate together to give a collision proxy, then hit Apply:
- The convex collision sliders allow for splitting the collision component into chunks to better fit concave shapes. Splitting it up too much can cause a slow calculation. Take the time to experiment with values to get the optimal result.
- Once you press Close, don't forget to save your asset.
- Place the mesh in the scene and press Alt + C to view the collision in the scene.
There's more...
Meshes that ship with UDK don't respond well to direct changes in the Static Mesh Editor. If you want though, you can place in the scene a mesh you've already copied to a new package, then highlight a new Material in the Content Browser, and right-click on the mesh in the scene and choose Materials | Assign from Content Browser. Changes in the scene like this aren't stored on the original asset, but on an instance saved with the map.