Hi,
I have a Main Camera with a Camera 2D Follow Component. I want to change the target of this script by script, using get component, but Get component don’t find “Camera2DFollow” As a component of the main camera.
How i can solve this?
//this script is attached to Main Camera//
using UnityEngine;
using System.Collections;
public class CreaNavicellaRandom : MonoBehaviour {
int rnd;
public GameObject Arancione;
public GameObject Azzurro;
public GameObject Bianco;
public GameObject Blu;
public GameObject Giallo;
public GameObject Nero;
public GameObject Rosso;
public GameObject Rosa;
public GameObject Verde;
public GameObject Viola;
// Use this for initialization
// Da aggiunger la posizione Randomica una volta detereminato lo spazio in cui possono muoversi le cellule
void Start () {
rnd=Random.Range(1,11);
switch (rnd) {
case 1:
Instantiate(Arancione);
break;
case 2:
Instantiate(Azzurro);
break;
case 3:
Instantiate(Bianco);
break;
case 4:
Instantiate(Blu);
break;
case 5:
Instantiate(Giallo);
break;
case 6:
Instantiate(Nero);
break;
case 7:
Instantiate(Rosso);
break;
case 8:
Instantiate(Rosa);
break;
case 9:
Instantiate(Verde);
break;
case 10:
Instantiate(Viola);
break;
}
GetComponent<Camera2DFollow> ().target = GameObject.FindGameObjectWithTag ("Player").transform;
}
// Update is called once per frame
void Update () {
}
}