playMaker

Author Topic: [SOLVED] Don't destroy object with multiple levels question/logic flow  (Read 3017 times)

Grave_sts

  • Playmaker Newbie
  • *
  • Posts: 24
Hi all~

I'm not quite sure how to approach this so I was wondering if someone could point me in the right direction ;)

Ok, here goes...I have a simulation setup where I show step by step how something is installed. At the bottom I have video player-like icons, with skip (forward/backwards) and return. The first "level" has the base which is used throughout, I have a "don't destroy" function on it. Everything works fine except for when for instance I let everything play and then decide to skip back to level one, there are then two instances of the base shown throughout.

Should I use a bool to test whether the base exists already and then delete the new/old one?
I'm open to any suggestions~
 
Thanks in advance :)
« Last Edit: May 30, 2012, 11:16:44 AM by Alex Chouls »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Don't destroy object with multiple levels question/logic flow
« Reply #1 on: May 29, 2012, 01:43:11 PM »
hi,

 it goes like this when I have to implement such thing.

 I simply do not have this object in the scene when it starts, I add it programatically, so that when the scene start I can simply ask or check a global var if it is there already or not, and instanciate it if not.

 This way, it works for all your scenes when you need to work on a specific scene, and it doesn't get messy when you play the whole thing.

I call this __MANAGER__ or something ( so that it's clear in the hierarchy what's "3d" and what's not. I have this on all scene, and it gets destroyed with the scene. I prefer this as querying from the object itself ( and destroy it if duplicate) because then I am sure nothing is processed ( like on Awake() for example).

so __MANAGER__ has a Fsm that check a global bool var "base is on" or something, if it's false, then I create that base from a prefab AND set "base is on" to true, next scene a new __MANAGER__ will check again and will find that "base is on" is true and therefore will do nothing.

 You can also "sort of" find this kind of set up in the Photon Demo, namely the enabled, you'll also see that the enabler GameObject is destroyed as soon as it did its job, which leave the scene cleaner.

https://hutonggames.fogbugz.com/default.asp?W859

The difference here is that various gameObjects are activated or destroyed based on whether or not the player is in a room. In your scene, it would simply a question of checking if you just launched the simulator or not and act accordingly.


Hope it make sense, else, do not hesitate, I'll try to reword or come up with a working example if you really get stuck.

 Bye,

 Jean

Grave_sts

  • Playmaker Newbie
  • *
  • Posts: 24
Re: Don't destroy object with multiple levels question/logic flow
« Reply #2 on: May 30, 2012, 01:42:38 AM »
Thanks~

Made perfect sense :)

Grave