my counter wont change from 0 help
my box Collider is triggered and my object (player) has a RigidBody
this is the score display script
#pragma strict
static var Counter : int= 0;
var test =0;
function Update(){
test = Counter;
}
function OnGUI()
{
GUI.Label (Rect (10, 10, 110, 110), "Score: " + Counter);
}
and this is the trigger Script
function OnTriggerEnter(other : Collider)
{
if(other.tag == "Player")
{
scoreDisplay.Counter += 1;
}
}
Check OnTriggerEnter is working or not . Add Debug.Log with if condition.
did your player have a RigidBody and a collider or only a rigidbody?
Because you need a collider on both objects to detect a collision.
Answer by atahhh · Aug 25, 2015 at 08:27 PM
i got that to work now i just had them in different layers.. does anyone know how to make a high score function well i got the text in the GUI but it resets back to 0 because i have it equal the same thing as my score
make a normal UI text with "Score:" and a blank for the score count right to it. Then just change the text of the score count. Then you don't have to use the OnGUI method.