I have tryed everything, i cant solve this because im a c# noob but I am sure that the solution is very simple.
It gives me an error “Static member cannot be accessed with an instance reference, qualify it with a type name instead” on the gameObject.Find()
using UnityEngine;
using System.Collections;
public class MissionManager : MonoBehaviour {
public GUIText timer;
public GUIText messanger;
//public GUITexture texture;
public int guiTime = 2;
public Transform arrowObject;
public Transform[] target;
private int currentTarget = 0;
private int moneyAmount = 0;
void Awake (){
messanger.text = "Recati alla pizzeria per cominciare le consegne";
messanger.gameObject.active = true;
//texture.gameObject.active = true;
// Start coroutine for deactivating gui elements
StartCoroutine(GuiDisplayTimer());
timer.enabled = false;
}
void Start(){
}
void Update (){
arrowObject.transform.LookAt( target[currentTarget] );
}
void OnTriggerEnter(Collider other){
if (other.transform == target[currentTarget]){
currentTarget++;
if(currentTarget >= target.Length){
currentTarget = 0;
}
}
if (other.transform == target[0]){
timer.enabled = true;
messanger.text = "Consegna la pizza entro il tempo limite";
messanger.gameObject.active = true;
//texture.gameObject.active = true;
// Start coroutine for deactivating gui elements
StartCoroutine(GuiDisplayTimer());
}
if (other.transform == target[1]){
moneyAmount = 20;
gameObject.Find("pizzeria").GetComponent (MoneySystem).GUIMoney.text = "$"+moneyAmount;
timer.enabled = true;
messanger.text = "Complimenti consegna effettuata 20$";
messanger.gameObject.active = true;
//texture.gameObject.active = true;
// Start coroutine for deactivating gui elements
StartCoroutine(GuiDisplayTimer());
}
}
IEnumerator GuiDisplayTimer(){
// Waits an amount of time
yield return new WaitForSeconds(guiTime);
// Deactivate GUI objects;
messanger.gameObject.active = false;
//texture.gameObject.active = false;
}
}
thanks