- Home /
How to Check if any object is at an specific Vector3?
Hello, Unity-Amigos
I've got an question... Is there a way to check if anything is at an specific Vector3?
Here's an example how i would do the start.
Transform objectAtVector3; /*(Note: This is unassigned)*/
public Vector3 specificVector3;
if(/*anything is at specificVector3*/)
{
/*get the object which is at the Vector3 and set him as the Transform*/
}
Hopefully this is not to confusing. Any help is appreciated
Comment
Answer by robertbu · Aug 02, 2014 at 06:02 PM
Assuming the objects have colliders, you can do it this way:
private Transform objectAtVector3; /*(Note: This is unassigned)*/
public Vector3 specificVector3;
Collider[] cols = Physics.OverlapSphere(specificVector3, 0.00001f);
if(cols.Length > 0)
{
objectAtVector3 = cold[0].transform;
}