playMaker

Author Topic: Save FSM State on Scene Switch  (Read 1953 times)

knownasa

  • Playmaker Newbie
  • *
  • Posts: 14
Save FSM State on Scene Switch
« on: March 29, 2017, 09:09:40 AM »
Hi guys! I am having this problem the last few days in which I cannot be able to make the following work: I have a flashlight system that is pretty straightforward - it's using a Spotlight and the LightShafts script for Unity and it's being activated/deactivated with Playmaker when you press 'F' ( to see it in action).

I don't seem to be able to get it to check if the flashlight was on or off when I switch scene with Adventure Creator. I have tried a lot of stuff, including DontDestroyOnLoad but it didn't work at all. I also tried saving a variable, but I don't know how to check it on Scene Switch!

Can anyone help? :)

terri

  • Sr. Member
  • ****
  • Posts: 386
    • terrivellmann.tumblr.com
Re: Save FSM State on Scene Switch
« Reply #1 on: March 29, 2017, 09:21:04 AM »
If you have a FSM on the flashlight that checks the saved variable, it should run as if reset when you switch scenes.

knownasa

  • Playmaker Newbie
  • *
  • Posts: 14
Re: Save FSM State on Scene Switch
« Reply #2 on: March 29, 2017, 11:08:15 AM »
If you have a FSM on the flashlight that checks the saved variable, it should run as if reset when you switch scenes.

What do you mean?

Ofonna

  • Full Member
  • ***
  • Posts: 230
Re: Save FSM State on Scene Switch
« Reply #3 on: March 29, 2017, 01:52:52 PM »
hi there, this is very easy, all you need to do is download player prefs bool from the ecosystem, at the beginning of every scene do a bool test to see if the flash light is on or not, when f is pressed to turn on your flashlight ensure you set prefs bool variable "on" to true and vice versa. if you still dont understand i can show you an example.

bye

knownasa

  • Playmaker Newbie
  • *
  • Posts: 14
Re: Save FSM State on Scene Switch
« Reply #4 on: March 29, 2017, 03:06:01 PM »
hi there, this is very easy, all you need to do is download player prefs bool from the ecosystem, at the beginning of every scene do a bool test to see if the flash light is on or not, when f is pressed to turn on your flashlight ensure you set prefs bool variable "on" to true and vice versa. if you still dont understand i can show you an example.

bye

Hey mate, it sounds simple indeed but can you show an example because I'm not sure of how to do this?

Ofonna

  • Full Member
  • ***
  • Posts: 230
Re: Save FSM State on Scene Switch
« Reply #5 on: March 29, 2017, 09:48:21 PM »
hi, in the image down below you see that i used "get player prefs bool" and then did a test in the start state. thats very important. your job is to use "set player prefs bool" when you activate/ deactivate your flash light. in your fsm you have a "get key down action" so when your flash light is activated "set player prefs bool" to true and when its is deactivated ensure you set "player prefs bool" to false.

now in the image you see an " ON" and "NOT ON" state all you have to do is activate your flashlight when on and deactivate it when off.