using System.Collections;
using System.Collections.Generic;
using UnityStandardAssets.Characters.FirstPerson;
using UnityEngine;
public class World : MonoBehaviour
{
public List<GameObject> characters = new List<GameObject>();
int currentChar = 0;
void Start()
{
// Disable all first
foreach (GameObject character in characters)
{
Character.GetComponent<FirstPersonController>().enabled = false;
}
// Enable only the one you want
characters[currentChar].GetComponent<FirstPersonController>().enabled = true;
}
void Update()
{
if (Input.GetButtonDown("Fire1"))
{
currentChar < characters.Length ? currentChar++ : currentChar = 0;
// Disable all first
foreach (GameObject character in characters)
{
Character.GetComponent<FirstPersonController>().enabled = false;
}
// Enable only the one you want
characters[currentChar].GetComponent<FirstPersonController>().enabled = true;
}
}
}