Building a rail shooter and learning JAVA script. want to call “currentScore” Varable from my _Master gameobject whenver you unload a object when its clicked on.
the unload script works but when itry to use _MASTER.Getcomponet or try to use
_MASTER.currentScore it has an error Unknown Identafier.
//code is on my Enemy object that is unloaded. wheni ts unloaded want it
to Add 100 Points to score and display in my "Master" game obect.
#pragma strict
function Start () {
}
function Update () {
if (Input.GetMouseButtonDown(0)){
var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
var hit: RaycastHit;
if (Physics.Raycast(ray, hit)){
_MASTER.GetComponent("currentScore") += 100;
Destroy(hit.transform.gameObject);
}
}
}
///////// the code for the master game object below.//////////
#pragma strict
static var currentScore : int = 0;
function OnGUI () {
GUI.Label (Rect (10, 10, 100, 20), "Score: " + currentScore);
}
///// I am trying to Lern this is really bugging me will be a good help thanks in advance Gang!