I’m just messing around with collisions with unity, so at the moment I’ve got it so when the player enters a certain area of the level they gain 10 experience and when they reach 100 experience points a notification pops up saying they have leveled up. When I try to run it in game it has an error that says "Expressions in statements must only be executed for their side effects, sorry if it’s something simple I’m pretty new to scripting ![]()
var detectcube : boolean = false;
var experience : int = 0;
function OnTriggerEnter() {
detectcube = true;
}
function OnTriggerExit() {
detectcube = false;
}
function OnGUI()
{
if (detectcube)
{
experience + 10;
}
if(experience > 100)
{
GUI.Box (Rect(10,10,200,50),"You have levelled up!");
}
else
{
GUI.Label (Rect(10,10,0,0),"");
}
}