How Do I Get An Object At Given Position?
Hi all, Im currently playing with some functions of Unity and C# and I found a question. How do I get all objects that are located on a certain (given)(2D) position let say x==1; y==2.
What I have done seems to work, but I have the feeling there has to be a better way to do so. My code so far: GameObject[] activeObs = GameObject.FindGameObjectsWithTag("SingleBlock"); foreach(GameObject gob in activeObs){ if(Mathf.RoundToInt(gob.transform.position.x) == 1 && Mathf.RoundToInt(gob.transform.position.y) == 1) Debug.Log("Object at position (1,1) is " + gob.transform.name); }
Your answer
Follow this Question
Related Questions
Rigidbody.position: How can i make my player to not leave the field 0 Answers
new Vector3(1, 0.25, -6); dont work 0 Answers
Get local position of pointer on scaled texture (2D) 1 Answer
tracking ip adress or location? 0 Answers
locate on the move,find the sequence number when the character moves 0 Answers