private var coinsBegin : int; private var coinsCurrent : int; var levelToLoad:int; //level to load private var coinToNext:int=10; //coin necessary to open next level
function OnGUI() { coinsCurrent = 0; var coinObjects = FindObjectsOfType( GameObject ); for ( var coinObject : GameObject in coinObjects ) { if ( coinObject.name == "coin" ) coinsCurrent++; }
GUI.Label( Rect( 0, 0, 320, 20 ), "Collected " + ( coinsBegin - coinsCurrent ) + " of " + coinsBegin + " coins!" ); }
function Start() { var coinObjects = FindObjectsOfType( GameObject ); for ( var coinObject : GameObject in coinObjects ) { if ( coinObject.name == "coin" ) coinsBegin++; } }
function Update() {
if (coinsCurrent == coinToNext ) { Application.LoadLevel (2); } }
stuck on this all day!! I am trying to modify a coin counter script so that after 10 coins collected, next level will load.
currently, script immediately loads next level when you press play to test, does not wait for you to collect coins...
what am i doing wrong?? thanks for you help...