- Home /
How to set a game area?
Hi, I am trying to create a Strategy game in Unity. At the moment you can build buildings and move units. Everything works fine, except that you can build buildings and order units outside my map. So now I am looking for an efficient way to check if a building is build or a unit is ordered inside the area of the map. I came up with several ideas like creating a huge box collider around the area, but then a collision event will be triggered every frame for every unit inside the box (which would be every unit on the map), and I dont think that is a ressource friendly option. placing colliders around the map would prevent units from going off it, but buildings could still be placed outside the colliders... And setting world coordinates for the maps corners isnt a good option either, as i dont know how big my map will be in the end... so if anyone has a good idea, thanks in advance.
Are you able to use some kind of tile-based solution?
Ins$$anonymous$$d of doing a collision check, could you just have variables for the boundaries of your level (Vector3), and then mathematically check that an object is within those boundaries?
Why are you checking every frame?
Answer by BLarentis · Aug 23, 2012 at 05:55 PM
If you use RayCast to check your click, you can check where you are clicking. So if you put a Tag into the objects that you want the things to be build, you will be able to check this tag and proceed or not with the construction. Take care !