playMaker

Author Topic: accessing persistent objects between scenes  (Read 3354 times)

tonyoakden

  • Playmaker Newbie
  • *
  • Posts: 1
    • View Profile
accessing persistent objects between scenes
« on: August 02, 2012, 05:17:32 PM »
Hello,  I'm new to this forum so I apologise if this topic has been covered before.

I'm instantiating a game object in the first scene of my game and I'm making it persistent in it's start script thus: "DontDestroyOnLoad (transform.gameObject);"

which works fine.  I can access it from playmaker in that first scene but I need to access it from playmaker in subsequent scenes.  Because the object isn't part of the hierarchy of objects in the next scene I'm not sure of the best way to do that.  I suppose I could find the object in a script which is attached to playmaker by searching for it by name but that seems a bit clumsy. Any ideas?

regards,

Tony

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 12351
  • Official Playmaker Support
    • View Profile
Re: accessing persistent objects between scenes
« Reply #1 on: August 07, 2012, 07:05:06 AM »
Hi,

 Never tested, but one way would be to store that gameObject reference in a global fsmGameObject variable, and thus would be accessible by anything at anytime even after scene loading. have you tried that?

bye,

 Jean

Damian

  • 1.2 Beta
  • Full Member
  • *
  • Posts: 188
    • View Profile
    • Permaximum Betty
Re: accessing persistent objects between scenes
« Reply #2 on: September 16, 2012, 03:16:51 AM »
Hi,

 Never tested, but one way would be to store that gameObject reference in a global fsmGameObject variable, and thus would be accessible by anything at anytime even after scene loading. have you tried that?

bye,

 Jean

Hi Jean.

I have started to make a new game. It do have many levels and I also interested in global gameobject(variable) that is transfer to the next level. Like score and health.
Can I use Global variable in Playmaker for that?
Dont they reset every scene?
 
 

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 12351
  • Official Playmaker Support
    • View Profile
Re: accessing persistent objects between scenes
« Reply #3 on: September 16, 2012, 03:36:43 AM »
Hi,

 Global variables will persist as you load levels yes, I just ran a test and the value persists.

bye,

 Jean

Damian

  • 1.2 Beta
  • Full Member
  • *
  • Posts: 188
    • View Profile
    • Permaximum Betty
Re: accessing persistent objects between scenes
« Reply #4 on: September 16, 2012, 04:07:14 AM »
Hi,

 Global variables will persist as you load levels yes, I just ran a test and the value persists.

bye,

 Jean

Thanks for the fast answer.
Now I can draw up that system.
I try to do as much I can with Playmaker with this game.
So I have to learn a lot to make it work like I want, even if I have some stuff in script that work good I still want to change them to Playmaker stuff.