Given this area
- - - - - X X - - X X - - - - -
I have a GameObject size 4x4 and inside another GameObject size 2x2.
I know how to calculate a random position inside the 4x4 zone (using GameObject position and collider size), but I do not know calculate a random position evading the 2x2 zone.
What I am using right now is:
- Calculate position inside 4x4.
- If that position is inside 2x2 go back to step 1.
But it is not a good way to do this. Do you know can I calculate a random position inside 4x4 area evading a 2x2 area?
I though generating small GameObjects, 1x1 instead if 4x4. So first select a random of the 4x4 tagged, for examble, as "IsWalkable", and then calculate a random position insided the selected small square.