playMaker

Author Topic: Make PlayerPrefs save ONLY if Player finishes the level  (Read 1072 times)

Brijac

  • Playmaker Newbie
  • *
  • Posts: 3
Make PlayerPrefs save ONLY if Player finishes the level
« on: January 16, 2021, 01:11:48 PM »
Hello, I'm having trouble make a level manager in my game and I was wondering if maybe I can do it with PlayMaker. I purchased it a while ago but unfortunately never used it.

This is an example of the game:


This is an example of the levels:


First level is unlocked in the beginning and you need to finish every level to unlock the next level. By finishing the level I mean getting to the finish collider at the end. Collecting points is optional and you can earn stars by collecting points.

The problem that I have is that I want that collected points only save if the player reaches that finish collider. It doesn't make sense that the player for example collects 70 points (which, lets say, gets him two stars), dies and still receives two stars. I want that the player earns those stars ONLY if he gets to the end, if he dies or just quits the game the points should delete and no stars should be awarded.

Is something like this possible with PlayMaker?
« Last Edit: January 16, 2021, 01:13:52 PM by Brijac »

heavygunner

  • Sr. Member
  • ****
  • Posts: 344
Re: Make PlayerPrefs save ONLY if Player finishes the level
« Reply #1 on: January 16, 2021, 01:58:17 PM »
This is what I would do.

For Levels. There will be an int variable called "Level" . When player reached finish, I will send and event LEVEL FINISHED and will use action Int add and will add 1 to "Level" variable. So, That will be 2. Then, will use action Playerprefs Set Int and save that "Level" variable in new key called "level"

Same for Stars. Fire an event at Level Finished and check how many stars. and Then will use Int Compare Range action and add stars. and save thm in different key via Playerprefs

Brijac

  • Playmaker Newbie
  • *
  • Posts: 3
Re: Make PlayerPrefs save ONLY if Player finishes the level
« Reply #2 on: January 16, 2021, 04:37:44 PM »
This is what I would do.

For Levels. There will be an int variable called "Level" . When player reached finish, I will send and event LEVEL FINISHED and will use action Int add and will add 1 to "Level" variable. So, That will be 2. Then, will use action Playerprefs Set Int and save that "Level" variable in new key called "level"

Same for Stars. Fire an event at Level Finished and check how many stars. and Then will use Int Compare Range action and add stars. and save thm in different key via Playerprefs

Do you maaaaybe have an example or something? I've never used PlayMaker before so this is all new to me.

heavygunner

  • Sr. Member
  • ****
  • Posts: 344
Re: Make PlayerPrefs save ONLY if Player finishes the level
« Reply #3 on: January 16, 2021, 08:43:37 PM »
This is what I would do.

For Levels. There will be an int variable called "Level" . When player reached finish, I will send and event LEVEL FINISHED and will use action Int add and will add 1 to "Level" variable. So, That will be 2. Then, will use action Playerprefs Set Int and save that "Level" variable in new key called "level"

Same for Stars. Fire an event at Level Finished and check how many stars. and Then will use Int Compare Range action and add stars. and save thm in different key via Playerprefs

Do you maaaaybe have an example or something? I've never used PlayMaker before so this is all new to me.
Did you created the game already ?

Brijac

  • Playmaker Newbie
  • *
  • Posts: 3
Re: Make PlayerPrefs save ONLY if Player finishes the level
« Reply #4 on: January 18, 2021, 10:23:54 AM »
Did you created the game already ?

I made something that I will upgrade with assets later, something like a prototype.

I've sent you a link to unitypackage if you want to check it out.