How to make an area inacessible?
I am making a top down shooter style, and I want to have small buildings, for example, which will house my enemy spawners. How can I make it so that the player can't go inside the area in the building, but still have enemies allowed to walk out? Enemies are nav mesh agents and the player isn't, if that makes any difference, and I'm using C#
Don't need full code (unless it's just a simple line then why not) but just a point in the right direction. Thanks in advance
Answer by Jason2014 · Jun 23, 2017 at 09:59 AM
You can try Layer-based collision detection. Add layer to player and that object which you want to be inaccessible, but only for player. Depending of what type of game you make (2D or 3D) you can go to "Edit -> Project Settings -> Physics (or Physics 2D, don't know how type you create). There you have a special Layer Collision Matrix which controls of collisions between all specific objects which contains a layer.
Remember: if you want add custom layers click "Edit -> Project Settings -> Tags & Layers -> Layers". It must be a "Layer", not "Sorting Layer".
Here you have more information about this: https://docs.unity3d.com/Manual/LayerBasedCollision.html