playMaker

Author Topic: Changing scene, array, easy save  (Read 553 times)

Microck

  • Playmaker Newbie
  • *
  • Posts: 4
    • View Profile
Changing scene, array, easy save
« on: March 11, 2019, 08:23:12 AM »
Hello ! Playmaker is a great asset, I'm glad with my purchase !  :)

However, I need some helps for a basic thing. I've been reading some topics but I'm still confused.  :-\
I want to know how to store things like Scene 1: The sphere is green. So that if I comeback to this scene 1, the game load the data and the sphere is still green.
I've bought Easy save 2 yesterday and I'm a bit lost.

I have a gameobject called Gamemanager with Don't destroy on load + singleton manager + Array list add (data type bool for the sphere).



And a gameobject Sphere with an Array list set (data type bool + variable called "CurrentObjectBool") and a set material color.





When I playtest the game, I interact with the sphere and he turn red or green.
I can see in the gamemanager that an "index 0" appears and is tick for green (see image above), untick for red.

So what is the FSM action for store the data and then, after switching scene tell the game if this data exist then the sphere is green ?
What I did wrong ?
I thought such a basic thing like this would be super easy.  :'(

PS: I want to avoid a autosave / constant save feature because I will let players save only if they are in a saveroom (like Resident Evil).

miguelfanclub

  • Full Member
  • ***
  • Posts: 152
    • View Profile
Re: Changing scene, array, easy save
« Reply #1 on: March 11, 2019, 11:58:17 AM »
You cant save game objects with ES2 (you can with ES3)

What I do:

1 I Add to an array the Game Objects I want to save when I perform the action I want for them to be saved (I open a door, i send the door to the array)

2 I set an status for each Game object as an int (door 0 = closed 1= opened 2= change material)

3 I use ES2 to save with two actions "Save Array String" (I save the name of the Game object) and "Save Array int"

For Load:

Go through the array to load the string to then find the object "Find Object" action
Do the same for the int array to send to that object its "status" and then send to this object to perform the load action.

Microck

  • Playmaker Newbie
  • *
  • Posts: 4
    • View Profile
Re: Changing scene, array, easy save
« Reply #2 on: March 12, 2019, 10:36:44 AM »
Thanks for the reply !
I think i've been overthinking. ;D
Actually I use global variables with my GameManager for keeping data between scenes and that works fine atm.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 4611
    • View Profile
    • jinxtergames
Re: Changing scene, array, easy save
« Reply #3 on: March 12, 2019, 11:55:49 PM »
Hi.
That's actually not a good practice.

Better would be to have a 'Meta' gameobject and store data there and use don't destroy On Load.
use Get/Set fsm actions to access the data.
you can have the metadata into a global if you want. But you can also use a 'find gameobject' at the start of a scene instead.

or you could load/save between scenes with es2

have a look at this wiki : https://hutonggames.fogbugz.com/default.asp?W1462

Microck

  • Playmaker Newbie
  • *
  • Posts: 4
    • View Profile
Re: Changing scene, array, easy save
« Reply #4 on: March 13, 2019, 11:53:43 AM »
Hi djaydino !
Hundreds of global variables can broke the game or increase loading time / fps issues ?

Have you an example for the Meta GameManager that persist between scenes please ?
I tried different actions, get / set FSM ("int") and the data is not send properly to the GameManager. So when I go to the scene 2 and back to the scene 1, the data aren't saved.

Basically I've a local variable "Result" (int) on the GameManager for storage purpose. And 3 actions: Dont destroy on load, singleton manager, get owner "GameManager".

When I interact with the sphere, I send a value to the GM variable "Result" with the action "Set FSM int".
Green material sphere = "Result" value 1
Red material sphere = "Result" value 0

At the start of the Sphere, I've a "init state" with 2 actions: Get owner "GameManager" and "Int compare" (integer 1 = "Result", integer 2 = 0) so that if I switch back to this scene, the sphere will be either red or green according to the local variable value "Result" of the GameManager.

But... that doesn't work. I guess I missed something important...


Microck

  • Playmaker Newbie
  • *
  • Posts: 4
    • View Profile
Re: Changing scene, array, easy save
« Reply #5 on: March 14, 2019, 08:01:55 AM »
EDIT:Still doesn't work after multiple retry.
The sphere stop sending data to the GameManager AFTER switching scene.

If I stay on the scene 1 and Interact with the sphere it's fine, the local variable "Result2" on the sphere and the local variable "ResultGM" on the GameManager have the same value.

BUT if I switch to the scene 2 and back to scene 1, interacting with the sphere doesn't affect the GameManager anymore (like the game doesn't recognize the GM).

EDIT2: Ok the problem was the GameManager. I was able to fix it by adding a new state. Problem SOLVED !
« Last Edit: March 14, 2019, 05:00:11 PM by Microck »