i have 2different player in a game i can swap these player just pressing a space button i want when i swap my player then camera follow new player
for the swapping i using this script
private var players : Array;
var normalform : GameObject;
var inflatedform : GameObject;
function Start ()
{
players = new Array();
players[0] = GameObject.FindWithTag("NormalForm");
players[1] = GameObject.FindWithTag("InflatedForm");
//players[2] = GameObject.Find("C3");
//players[3] = GameObject.Find("C4");
players[0].gameObject.SetActiveRecursively (true);
players[1].gameObject.SetActiveRecursively (false);
//players[2].active = false;
//players[3].active = false;
}
function Update()
{
if(Input.GetButtonDown("Normal"))
{ players[1].gameObject.SetActiveRecursively(false);
players[0].gameObject.SetActiveRecursively(true);
players[0].transform.position.y+=3;
players[1].transform.position=players[0].transform.position;
}
if (Input.GetButtonDown("Inflated"))
{
players[0].gameObject.SetActiveRecursively(false);
players[1].gameObject.SetActiveRecursively(true);
players[1].transform.position=players[0].transform.position;
}
}