- Home /
Physics.CheckSphere with tag
I want to put a game object at a specific location only if a game object with the same tag is not nearby.
I have the point in which I want to check. Say, (0,0,0). I want to check if a game object with tag "grid" is located at (0,0,0). If no object with tag "grid" is located at (0,0,0), then I will put a game object there.
Comment
Answer by Casiell · Dec 03, 2018 at 08:00 AM
Physics.OverlapSphere sounds like what you need. It returns an array of colliders and you can check if any of those colliders have a tag you are looking for. Good thing to do would be to assign a layer to objects you want to find (instead or in addition to tag) and feed that layermask to OverlapSphere function.