- Home /
Found if instantiate position already occupied
How can I know if the position where i want to randomly instantiate a new object it's already occupied? I tried with Spherecast, but without result.
Do you have a grid like system? If so, you could change the state of the grid to occupied when something is on it and change to a new random location when hitting an occupied one.
I'm actually working on the same problem right now. I don't have a grid, so I added rigid bodies and small scripts to the objects I'm instantiating that set a boolean in them to either true or false when they enter/leave the collider triggers.
Then I use my instantiating code to check the booleans before instantiating. Works almost perfectly, except the objects can't be touching. I want them to be touching, just not inside of each other...
Your answer
![](https://koobas.hobune.stream/wayback/20220613104741im_/https://answers.unity.com/themes/thub/images/avi.jpg)