My journey becoming a Unity game developer: Make a game look beautiful-Creating colliders in the Control Room pt.1
Objective: Create colliders in the Control Room which will be used to prevent characters from being able to move through different game objects.
We want to add colliders to the Control Room, preventing the player character and other characters from moving through the game objects that make up this scene.
We will start by adding a collider to the floor. Let’s begin with creating an Empty game object name Colliders which will hold all of the colliders being used in the Control Room. Inside of the Colliders object, create a Cube object which we will use as a collider itself. The Cube object will automatically have a Box Collider attached to it, making the Cube object ideal for most of the game objects in the scene. Position the Cube in the middle of the floor, and scale it out to cover the entire floor from the Control Room to the hallway.
Duplicate the Cube used for the floor’s collider, and align it to one side of the wall. Rotate and scale this cube to match the size of the wall, and position it to be in front of the wall itself to keep characters from moving through this wall. Duplicate this Cube and place it onto the other side wall across the room.
Duplicate a Cube from one of the side walls to be used for the back wall. Rotate, scale, and position this Cube along the back wall with the collider in front of the wall.
Duplicate one of the side walls Cube objects to be used for one side of the front walls in the Control Room. Rotate, scale, and position this Cube in front of that front side wall. Duplicate this Cube object and position it along the other front side wall across the room.
Duplicate one of the side walls Cube objects once again to be used for the hallway walls. Position and scale this Cube object along one side of the hallway’s walls. Duplicate this Cube object and position on the other wall in the hallway.
To create a collider around the columns, we will use the Column 01 prefab. With the Column 01 prefab selected, use the Add Component to attach a Box Collider to the column. Scale it to fit around the column from top to bottom. Remember that by making these adjustment inside the prefab, these changes will automatically be made to all of the Columns 01 objects in the Scene.
We will now add colliders to the columns used in the Door Archway in the front of the Control Room. Create another Cube inside of the Colliders object, place it inside the middle of one column. Scale this Cube object to fit along the size and length of this Column 02 object. Duplicate this Cube object and place it across to the other Column 02 object.
Now we need to create colliders along the Doorway. Create another Cube object, scale this object to fit one side of the Doorway to the side of the Main Door. Duplicate this Cube object, and position it on the other side of the Main Door to fit along the side of the Doorway. Duplicate this Cube object once more, but this Cube object will be scaled and positioned in the middle of the Doorway above the Main Door.