A Guild to Beautiful Games
Adding In Colliders to our environment
Now that our scene has been somewhat completed, it is time to add in our colliders for the walls and other static objects. There are several methods in adding in colliders, but the since the scene is already filled with complex shapes and textures, its best practice to lessen the load on the processing power, therefore when adding in colliders the more simple it is, the better.
Floor and Wall Colliders:
The general rule for making colliders is that, unless you want things to bounce off the ceiling, the roof shouldn’t have any colliders. As for the walls and floor, I created a new 3D cube and flatten the the shape into a plane, this cube would be stretched across all walkable platforms (except for stairs).
As for the walls I basically took the floor collider and duplicated it, then flipped so it is parallel to the walls and slowly build my way around the walls, with each side getting their own collider. The only wall which will need to be concerned about is the main front doorway where you want to avoid adding a wall collider blocking the door.
As for the column colliders, since they stick outside the wall colliders they might result in a weird effect if the players make contact with them. Therefore we will need to add another collider for each column, lucky since each column is an prefab all we need to do is add one cube with a box collider and the rest should automatically gain the same.
Start by entering the isolation mode, where you click the > on the hierarchy. Then we can manually add in a new 3D cube and adjust the size so it match in both height and width of the column, the more it covers the closer the collider is going to be when matching to the actual column. Finally we can turn off the mesh renderer of the cube to present a transparent collider!
We can apply the same process to the archway in the main hall.
Once that is all completed we are going to create a new folder in the hierarchy to house every single wall and floor collider (excluding the columns since they themselves belong within their own prefabs). Then we can turn off all the Mesh Renderers to make all the colliders transparent.
Once you are completed it is time to test our colliders to see if they are exactly how to want them to be.
Testing our Colliders:
To test our colliders, we can download the free Unity Starter Asset pack “First Person Controller”
If you don’t have this asset pack you can find it in the Unity Asset store which is now all online. Once that has been added, you can find the actual files within the package manager. Search for “Starter Assets — First Person” and this should pop-up. Download and then import into your project.
Once that is completed, you are going to see a new tab on the top of Unity controls call “Tools”. Within it, you are going to see the Starter Assets which you can then reset the First Person Controller.
Two new objects are going to be created in the hierarchy and you will see a brand new capsule on the scene. The main camera is also going to be controlled by this new player object.
Once you hit the play button, you will see that you will have full control over the player. Now you can fully test out the walls and floor colliders to see if they are at the right position.
Tip: If you find that your character controller is falling through the floors, you can lift the player controller up a tad bit so all of the player colliders are above the floor colliders.