- Home /
This post has been wikified, any user with enough reputation can edit it.
Question by
Gabigabigo · Apr 25, 2014 at 02:13 PM ·
collidernamegame object
Get the name of a game object with position ?
I'm creating a Sokoban game and I want that my player push the crate.
I found how to detect if there is a game object in front of the cube, but I don't know how to get the name/tag of the cube, so I can't push the crate.
Actual code :
checkPosition = transform.position + Vector3(0f,32f,0f);
hitColliders = Physics.OverlapSphere(checkPosition, 1);
if(hitColliders.length < 1)
transform.position.y += 32f;
Sorry for the faults, English is not my mother language.
Comment
Answer by Graham-Dunnett · Apr 25, 2014 at 02:47 PM
The script at:
http://docs.unity3d.com/Documentation/ScriptReference/Physics.OverlapSphere.html
shows how to iterate over the objects that the test has found. Inside the while loop just Debug.Log the name of the collider.
Your answer