so i am trying to generate a Level. So i wrote a littel script which creates me my Planes for the level (recursive).
Now i want to check if there is allrdy a gameObject been created at a specific position ?
How to do this ?
I was thinging about this:
or a Gameobject holding a list of all GameObject based on theyr coordinates, and just check this list if there is allrdy a Item on this position !? What is more easy to accomplish ?
I doubt you want Physics.SphereCast(). Instead take a look at Physics.CheckSphere() or even Physics.OverlapSphere(). Note all three of these require the planes to have colliders.
What method you choose depends on the number of elements you are creating, when you are creating them (i.e. while playing vs. at Start()), and whether they have colliders. The most efficient method would be to keep your own list and compare the distance. If you tag all the objects as you go, you can generate a list using GameObject.FindObjectsWithTag(). Not as efficient, but probably better than PhysicsCheckSphere().