Hey everybody,
I was hoping somebody could help me out a bit.
What I'm trying to do?
- Increase Score by 1 when the collision happens - This works
- Add that Score to PlayerPrefs and Show it at the Beginning of the New Scene - This Works
- Add +1 to currentGameScore when the collision happens - **Not sure how to do this part**
- Add the new scenes currentGameScore to the previous scenes currentGameScore **Not sure how to do this part**
- Start the Next Scene with the total of all currentGameScores **Not sure how to do this part**
So basically, if I got 4 points on the first level, I then start the second level with 4 points.
I then get 3 points on the second level which gives me a total of 7 points.
I then start the third level with 7 points and get 2 points.
I start level 4 with 9 points.
Etc, etc.
My code so far:
function Awake(){
guiScore.text="SCORE " + PlayerPrefs.GetInt("currentGameScore");
}
function OnCollisionEnter(theCollision:Collision){
if (theCollision.gameObject.tag=="myTag"){
currentGameScore+=1;
PlayerPrefs.SetInt("currentGameScore",currentGameScore);
PlayerPrefs.Save();
}
I think I need another variable, but not sure how to go about using it.
I'm sure this is pretty basic, but I'm stumped.
Any help is really appreciated.
Thanks in advance!
↧