Welcome. I’m trying to create a script that adds a button is pressed var number 1 I mean the counter, which will be summed up how much we have collected things. Unfortunately, this counter is not working and is not added to 0 numbers. Sorry for bad english, but I am writing this with google translator.
Here is the code:
var tekst : GUIText;
var fpc : GameObject;
var bron : GameObject;
var vis : boolean;
var Hand : GameObject;
var distance;
var coconut = 0;
static var bronZabrana : boolean = false;
function OnBecameVisible() {
vis = true;
}
function OnBecameInvisible () {
vis = false;
}
function Update()
{
distance = Vector3.Distance(bron.transform.position, fpc.transform.position);
if ((distance < 1.1) (vis == true))
{
tekst.enabled = true;
if(Input.GetKeyDown("f"))
{
bronZabrana = true;
tekst.enabled = false;
gameObject.active = false;
bron.transform.parent = Hand.transform;
function OnTriggerEnter (other : Collider) {
coconut++;
}
}
}
if ((vis == false) || (distance > 1.1))
{
tekst.enabled = false;
}
}
function OnGUI () {
GUI.Label (Rect (10, 10, 100, 200),"pozostałe części: " + coconut + " /10");
}
I don’t think you are making your search in the right script, you have a syntax error in script podnoszenie.js which contents a OnTriggerEnter function which is not present in the script you pasted.
Syntax error is because you did not write the code correctly. Error should take you to the line where there error is and make sure you enter code correctly.
Post the code from podnoszenie.js if you want people to take a look at it.