- Home /
Can't go into building because of collider around it
To set up the scenario, I have a building with a hole, a passageway if you will, bigger than the character. At the moment, the character is a cube. The character has a rigidbody and box collider. The building has a mesh collider and a rigidbody. I want the character to be able to just casually walk into the building and look at what is inside it.
My problem is that there is a collider around the entire building so I cannot walk straight into the passageway. I want to be able to walk into the hole, but I cannot find a collider that I can only apply to the walls and not the passageway.
How can I fix this so the passageway exists, the building has a collider (so stuff cannot just walk through the walls), and so the character can walk into the building without a problem?
Is it possible for you to edit the model of the building? With a mesh collider your character/cube should be able to walk anywhere in the building as long as there is no mesh in the way. $$anonymous$$aybe you have some transparent wall blocking the entrance way?
A brute force approach would be to use a bunch of box colliders and leave the door open. Since a game object can only have one collider of each type, you would need to put them on empty child objects.
Indeed, it would be a poor game without a flying house....
Answer by lukejaparidze · May 07, 2013 at 04:23 AM
it usually depends on the model that you use. when unity generates mesh colliders, it takes every object in it. use the transform tool and click on your passageway (assuming that your building isnt just one giant mesh) in the properties, disable or delete the mesh collider on the object. good luck :)
What if it is one big giant mesh imported from Blender? Is there a way to get rid of colliders on the empty space and just put colliders on walls?
Don't check "convex". The point of a (non-convex) mesh collider is that it matches the mesh.
But then it is too easy for the player to go through the wall at a high velocity.
You must not check convex. That's the only solution. As for going through walls, why are you allowing the player to achieve velocities so high in the first place?
Well, if the player were to board a spaceship and move around in it at the same time the spaceship is moving, there would be a high velocity.
Answer by 10001110101 · May 07, 2013 at 11:39 PM
I would break the mesh up into modular assets with separate collision. It will create a modular asset set that will allow you to build more than just one building. It will also allow you to figure out where your collisions are becoming problematic.