- Home /
This question was
closed Jan 02, 2012 at 11:22 AM by
DavidDebnar for the following reason:
The question is answered, right answer was accepted
Question by
DavidDebnar · Nov 26, 2011 at 11:38 AM ·
collidervectorpoint
2D Array for pathfinding
Hey guys! Is it possible to make a editor function which would build a 2D array depending on objects? I want to use it for pathfinding so what I need is if there is a collider it sets the point to 0 of there is nothing is sets it to 1.
Comment
Yes it is possible. Not quite as straightforward as you think it is, though. Are all the objects in a plane? Or are they on several levels? You need to know how large your grid is, but otherwise you can use Physics.CheckSphere or Bounds.Contains with your grid coordinates to find colliders.
Well, then just iterate through the locations on the grid and use
if(Physics.OverlapSphere(whatever).Length < 0)
{
// that location is filled.
}