Hello,
i want to ask how to link two scripts because i want to make a counter that is shown in a score box.
I created a var “ScoreCounter” and a seperate script for my Score but i can’t import the var form one script to the other
script for the GUI
#pragma strict
var Pos1 : float = 400;
var Pos2 : float = 15;
var Pos3 : float = 155;
var Pos4 : float = 25;
function Update () {
}
function OnGUI () {
// Make a background box
GUI.Box (Rect (Pos1,Pos2,Pos3,Pos4), "Score: " + ScoreCounter);
}
script for the counter
#pragma strict
static var ScoreCounter : int = 0;
var touchCoin : boolean = false;
function Update () {
if(touchCoin == true)
{
Destroy(gameObject);
ScoreCounter += 1;
Debug.Log("Destroy Coin and add 1");
}
}
function OnCollisionEnter2D (coll: Collision2D)
{
if(coll.collider.tag == "Player")
{
touchCoin = true;
Debug.Log("Coin is touching");
}
}
I hope somebody is able to help me
Greetings GreenTee