Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: volcank on July 21, 2018, 08:14:44 AM

Title: How to save score when game restarts[SOLVED]
Post by: volcank on July 21, 2018, 08:14:44 AM
Hi,

I am making like a loopable game where if the player reaches and the game restarts only the whole color theme will be changed and I will like add 1 to the Level Progress Bar so it will give the illusion of level progress. I make random scenes using object pooling. The thing is  I want to have the final score that player earned when the game restarts. If the player has 100 points at the end of level I want the game to restarts with 100 points. But if game is over I mean player dies then naturally the score should set to 0.

I used playerprefs for saving highscores so I can save highscore only couldn't implement that in saving score when player restarts the game. Or should I make different scenes (levels) to player will jump to next one and maybe there is a way to save score when jumping to a scene?? I would appreciate any help.

Thank you
Title: Re: How to save score when game restarts
Post by: blackant on July 21, 2018, 08:40:31 AM
simply put your score in a global variable to keep it through any levels
Title: Re: How to save score when game restarts
Post by: volcank on July 21, 2018, 06:08:57 PM
Hi, thank you it almost worked only like when the game restarts it shows 0 points but when I score my first point then it adds the score of the previous game and continues like that! Is there a way to show the score at the beggining??
Title: Re: How to save score when game restarts
Post by: volcank on July 21, 2018, 07:15:08 PM
Ok I did it! Thank you so much! My thing was I was calculating the starting x point and the current position x point of the player subtracting it and adding it  as score so giving a score for distance but of course when game restarts the position was also 0 again that is why it reflected at top as 0 when the game started. now I add score like every second but will find another way to add score like killing and enemy or something else.

Thank you so much for the help.