I want to create an array that is only root game objects with the tag “player”
GameObject players = GameObject.FindGameObjectsWithTag(“Player”);
I want to create an array that is only root game objects with the tag “player”
GameObject players = GameObject.FindGameObjectsWithTag(“Player”);
// Add using System.Collections.Generic;
at the top of your file
List<GameObject> players = new List<GameObject>( GameObject.FindGameObjectsWithTag("Player") ) ;
// Loop from end to start since we might remove elements
for( int i = players.Count - 1 ; i >= 0 ; --i )
if( players*.transform.parent != null ) players.RemoveAt( i ) ;*