- Home /
points system with coins
hey guys what is a good script for passing through a coin getting a point, then coin is destroyed, and after so many points getting to a next level/beating the game please help this is one of my final touches but of corse a big part
Answer by Alex 9 · Apr 21, 2011 at 03:45 AM
Script for the Coin
function OnTriggerEnter(hit : Collider){
if(hit.gameObject.tag == "Player"){
//add a tag to the player called Player, or just
//replace it with your tag if you already have one
ScoreSystem.myScore += 1;
Destroy(gameObject,0.0);
}
}
Attatch this Script anywhere but name the Script "ScoreSystem" (this is very important)
static var myScore = 0; var DelayTime = 10; function Start(){ myScore = 0; Invoke("myFunction", DelayTime); }
function OnGUI(){
GUI.Label(Rect((Screen.width / 2) + 20,10, 200, 30), "Score: " + myScore); }
Attatch This Script Anywhere as well
function Update(){
if(ScoreSystem.myScore == 10){ //change the 10 to however many coins there will be
Application.LoadLevel("YouWon");//Make a scene named "YouWon" and add it to the build
}
I hope this helps. Please review this code and learn from it.
what do i do? it says trying to Invoke method: ScoreSystem.myFunction couln't be called
$$anonymous$$ 9, can you tell that how the score of previous level would be added to next level starting score, Because it seams from your script that it would start with "zero" every-time!
Answer by prajyoth · Jun 30, 2015 at 04:34 AM
Using playerprefs could solve the problem of coins reloading.
PlayerPrefs.setint("score",myscore); //this will set the coin value
PlayerPrefs.Getint("score"); // this will get the stored coin value
Answer by idurvesh · Jun 30, 2015 at 05:07 AM
Soomla has pretty good Scoring system with lots of features icluding social sharing,achievements ,IAP and lot more for FREE, have look at it, http://soom.la/
Your answer
Follow this Question
Related Questions
Problem About Gaining Points 1 Answer
Who can help me with lock/unlock and hint/coin systems? 0 Answers
2D Coins and Points 1 Answer
point system for car game 1 Answer
Points based combat system | help 0 Answers