Because we should be able to walk through the middle of door frame, box and convex colliders are not suitable for our purpose. Due to that, we’ll add a triangulated mesh collider for door frame. Triangulated collider shape takes the polygon mesh and builds its shape based on that mesh. First of all, make sure that your door frame is selected. From the main menu, go to Modify | Geometry | Physics. This will bring the Physics Editor which lets you generate a physics collider for selected mesh. Make sure to use the following values for designated parameters:
- Type : Triangulate : Length
- Percentage: 100
- Density : 0
- Trigger: Unchecked
- Invisible Geometry: Unchecked
Percentage property is valid for triangulated colliders and specifies the percentage of number of polygon mesh vertices. Default values is 50, meaning that triangulated mesh collider uses half the amount of polygon mesh vertices. We want to create an accurate triangulated collider based on all vertices of our door frame. So make sure to set this property to 100.
You cannot specify a non-zero density for triangulated colliders, meaning that triangulated colliders are static colliders.
We don’t want to generate a trigger based on the shape of our door frame. So make sure to uncheck Trigger property.
Finally, we don’t want to create an invisible door frame with collider, so make sure to uncheck Invisible Geometry as well.
Press Generate button to generate the collider and hit OK to close the Physics Editor dialog.