playMaker

Author Topic: Help on Reload scene playmaker  (Read 5951 times)

nabilfx

  • Full Member
  • ***
  • Posts: 186
Help on Reload scene playmaker
« on: June 03, 2015, 07:18:03 PM »
I have a game with 3 levels. It is possible to store the float value in another var, even restarting in the same scene. Without changing to another scene.

Let say, i have scene 1, the at the end of 8 second, the scene 1 loads again.
But the result of my float var would be saved in another var, so in the end i can get the 3 float values score and make the sum.
« Last Edit: June 07, 2015, 04:26:00 PM by nabilfx »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Help on restart playmaker
« Reply #1 on: June 04, 2015, 12:13:05 PM »
Hi,

 what you need is a way to save data on a per scene base, and for this, you can use PlayerPrefs.

 each scene would have specific PlayerPref Key, like "Level X" x would be 1 2 3 depending on the scene.

then you end up with playerprefs like so:

"Level 1" -> 4
"Level 2" -> 9
"level 3" -> 2

4, 9 2 being made up values for each of your levels score.

 then, when you want the total, either you compute it on the fly, or you go through all playerprefs and add them in turn.

Bye,

 Jean

nabilfx

  • Full Member
  • ***
  • Posts: 186
Re: Help on restart playmaker
« Reply #2 on: June 04, 2015, 12:18:22 PM »
i can use this PlayerPrefsQ ?

nabilfx

  • Full Member
  • ***
  • Posts: 186
Re: Help on restart playmaker
« Reply #3 on: June 04, 2015, 12:21:17 PM »
show me how to do it please, with playmaker.

dudebxl

  • Hero Member
  • *****
  • Posts: 602
Re: Help on restart playmaker
« Reply #4 on: June 04, 2015, 12:56:46 PM »
hey,

don't use PlayerPrefsQ for that. PlayerPrefsQ is for large data I/O to txt file.

use 'PlayerPrefs set float' (w/ 'PlayerPrefs get float') from action tray.

When i first started i used this as a reference: http://hutonggames.com/playmakerforum/index.php?topic=344.0

hope it helps
« Last Edit: June 04, 2015, 03:26:59 PM by dudebxl »

nabilfx

  • Full Member
  • ***
  • Posts: 186
Re: Help on restart playmaker
« Reply #5 on: June 04, 2015, 02:07:42 PM »
i have Random Float, stored in a Float var 1
I put PlayerPrefs Set Float with Count 3, them put the var 1, var 2, var 3
but i dont now how to tell playmaker when reload the scene it needs to save the next float in var 2, them reaload again and save it in var 3

give me a help?

nabilfx

  • Full Member
  • ***
  • Posts: 186
Re: Help on restart playmaker
« Reply #6 on: June 06, 2015, 04:57:12 PM »
on reload the same scene, i need to tell playmaker to save the score in another float var.
« Last Edit: June 07, 2015, 03:52:02 PM by nabilfx »

nabilfx

  • Full Member
  • ***
  • Posts: 186
Re: Help on restart playmaker
« Reply #7 on: June 07, 2015, 03:49:16 PM »
...

dudebxl

  • Hero Member
  • *****
  • Posts: 602
Re: Help on restart playmaker
« Reply #8 on: June 07, 2015, 04:30:50 PM »
Dude,

jeanfabre explanation is clear no?

Anyway, I will give it a try:

Create 3 playerprefs float + 1 playerprefs Int. 3 for the Float Var and 1 for the count (int)

set count in playerprefs to 1 at start of game (first time it opens)
end of round 1 - set float to playerprefs var1 and playerprefs count to 2
start round 2 - get count number + have an int switch for count  - go to fsm/action for var 2, get float and save playerprefs var2 + add 1 to int count / save int count to playerprefs (playerprefs count).
** do the same for var 3 + get all var and sum it up for final score.

You need flags (1) use action ApplicationEventsBridge - download ApplicationEventsBridge from EcoSystem (if game is for IOS read this: http://docs.unity3d.com/ScriptReference/MonoBehaviour.OnApplicationQuit.html) - when application quit reset playerprefs count to 0. + (2) have a if count is above 3 or below 0 to reset playerprefs count to 0 and restart. + (3) end of round 3, reset playerprefs count to 0 and all other data.

The above explanation is not really the best method but should help..
« Last Edit: June 07, 2015, 04:33:33 PM by dudebxl »

nabilfx

  • Full Member
  • ***
  • Posts: 186
Re: Help on Reload scene playmaker
« Reply #9 on: June 07, 2015, 04:53:08 PM »
It is possible to reload the same level and start in another FSM?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Help on Reload scene playmaker
« Reply #10 on: June 08, 2015, 01:55:56 AM »
Hi,

 Technically speaking, no, if you start a level, all fsm that are active in that scene will be starting. but you can maintain flags that an fsm would check to detect if it needs to run or if it should stop.

 Bye,

 Jean

nabilfx

  • Full Member
  • ***
  • Posts: 186
Re: Help on Reload scene playmaker
« Reply #11 on: June 08, 2015, 04:38:24 PM »
How can i add Flags

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Help on Reload scene playmaker
« Reply #12 on: June 15, 2015, 07:55:57 AM »
Hi,

 a "flag" is a simple FsmBool that you can set to true or false in various places of your fsm, so that your fsm can take different decision based on this boolean state.

Does that make more sense?

Bye,

 Jean