Hi guys, I have three game objects and three locations, and I want to respawn them in a different location.
Each time after destroying them, is there a way to check if the position is empty before respawning them?
Thanks
There are a couple different approaches you could use.
**
- Check if there is physically any object occupying the space by using something like Physics.SphereCastAll to check for colliders around the space. Upsides: quickest to implement Downsides these spaces can be blocked by any colliders, and this method is more CPU intensive.
**
- You can just keep track of which spaces are occupied manually, for example having a
Dictionary<Vector3, GameObject>that you use to associate each position with the game object that is occupying it. So when you spawn an object you can set that position as occupied, and when you destroy an object you can set the position’s corresponding object to null