Hi! I am trying to get all the objects with the tag “Movable” from the scene and inserting them into an array of Gameobjects. i have looked over examples from documentation but it does not seem to be working. Here is my code:
public GameObject[] MovableObjects;
void Start()
{
MovableObjects = Gameobject.FindGameObjectsWithTag("Movable");
foreach(GameObject objects in MovableObjects)
{
Debug.Log(objects);
}
}
I do not see anything in the console so clearly MovableObjects is empty.What am i doing wrong?
did you dibug.log moveableobjects just to make sure it is null
– 767_2i just added this if(objects == null){ Debug.Log("null");} and it is not showing null
– RedDevilok so upon adding more debug.logs i see it does not even enter the foreach loop
– RedDevilalso MovableObjects is not null and if i try to see what it contains it returns nothing
– RedDevilmaybe the tag is movable not Movable or another typo mistake like that
– 767_2