Answer by spooneystone · Nov 01, 2016 at 10:17 PM
Look at Physics.Spherecast in the docs. It should return the first collider. all you need to do is do a "If" to check the tag "Blocks".
I think you misunderstand me :D I dont want it when it is collided I want it just in general
Physics.Spherecast doesn't check for a collision with player. it send a invisable sphere around your gameobject and collect information from all the gameobjects (if they have a colllider) inside the invisable Sphere. Its sounds more complicated than it is , Check out the Docs.
Im doing it in 2D so I assume I need to use Physics2D.CircleCast. I only want it to tell me if there is an object with a certain tag close, not just the closest object
Answer by sxnorthrop · Nov 01, 2016 at 10:45 PM
Try this: http://answers.unity3d.com/questions/15229/geting-the-closest-object-from-a-array.html
And use Physics.OverlapSphere
to get all the colliders nearby. Then just use a simple if
to check for the collider's tag.