- Home /
How can I do that in an array with gameobject.findobjectoftype but that does not count the same object in which this script is?
Hello, in a gameobject I need that in an array find all the gameobject with a specific script, the problem is that this object also has the script and I do not want it to be put in the array, does anyone know how to avoid it?
Answer by DawdleDev · May 01, 2018 at 12:04 AM
foreach (GameObject obj in GameObject.FindObjectsOfType()) { if (obj != GameObject) { ListName.Add(obj); } } Hope this helps!
Your answer
![](https://koobas.hobune.stream/wayback/20220612161816im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Calculating Scrolling GameObject x position scrolling pass another GameObject x postion (2D Game) 1 Answer
Get transform component from all gameobjects with tag 2 Answers
How do I play gameobjects in my scene from one script / Script is not working 0 Answers
Find GameObject with value within script 2 Answers
Index out of bounds even tho it shouldnt be [Javascript] 1 Answer