Hi!
I am facing a quite problematic issue here. What I want to achive is to spawn random objects (from 12 builded prefabs) in the random places - but the place itself cannot be totally random - it has to spawn itself with accordance to some rules. What I mean by that is something i put on the screen:
![alt text][1]
[1]: /storage/temp/129529-screenshot-1.jpg
As you can see the outside of the maze is let's say hard-builed - it never changes. The interior normally is empty. I want to spawn some random objects inside as on the screen. There are two boxes - each one of them has different shape and different sizie. These objects has to be placed two grid-tiles away from the outside of the maze and from each other as on the screen. Everything this has to be checked by script and by the same script these objects should be positioned. In the theory it sounds quite easy (at least I thought like that) but there are some problems persisting. First of all - the actual position of the boxes. Since these are having different shapes (some of them are in shape of "L", others are in shape of "T") it's hard to get exact size or position of the boxes - I can't simply get their bounds either. Second problem is that that I have no idea how am I suppose to align these boxes to the grid. The third problem how to actually check if the position is valid to put another object. Every object takes place not only as it is seen but also it takes space around itself (So there is an actual space of two tiles between each obstacle). Moreover, boxes seems to have a different idea of coordinates - for example (X,Y) = (3,3) - will be different for, I don't know, the box numer 5 and the box number 3 - making it even more complicated. Is anyone able to help me out with this? I'm really running out of ideas.
↧