Arrays
Tutorial
·
Beginner
·
+10XP
·
5 mins
·
(1737)
Unity Technologies

Using arrays to collect variables together into a more manageable form.
This tutorial is included in the Beginner Scripting project.
Previous: Instantiate
Next: Invoke
Languages available:
1. Arrays
using UnityEngine;
using System.Collections;
public class Arrays : MonoBehaviour
{
public GameObject[] players;
void Start ()
{
players = GameObject.FindGameObjectsWithTag("Player");
for(int i = 0; i < players.Length; i++)
{
Debug.Log("Player Number "+i+" is named "+players[i].name);
}
}
}