playMaker

Author Topic: Resetting a Game Object and its children within a scene [SOLVED]  (Read 4147 times)

jalex19

  • Playmaker Newbie
  • *
  • Posts: 27
So I store all of my "levels" currently in one scene, under different game objects (ex. Level 1, Level 2, etc) with children, and use FSMs to call them up, and disable them when done. My problem is if the player goes back to try and play an older level, nothing is reset!

I read the topic here: http://hutonggames.com/playmakerforum/index.php?topic=1014.0 talking about loading new scenes, but I don't think that's what I want here, since I would like to do this all within one scene if possible.

I'd like to know how to reset one of these parent game objects and all of their children to the point where they existed at runtime (transforms all reverted, destroyed objects re-created etc).

This might be more of a general unity question because I'm not even sure if it's possible to do this - but I hope so, because it would seem inefficient to have to make a new scene for each level, when the assets do not change much at all.

I am making great progress so far with playmaker in making my little game in the few hours of spare time that I have, and I very much appreciate the community help here!
« Last Edit: April 07, 2012, 03:38:33 PM by jalex19 »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Resetting a Game Object and its children within a scene
« Reply #1 on: April 05, 2012, 12:45:56 AM »
Hi,

 You will likely have to design your own reseting system.

 Otherwise, yes loading level seems the way to go. do you know that you can also load a level additively to the scene. So if you want to reset, simply destroy that gameObject and load additively the level with that gameObject.
 Of course, depending on what you want, you still might have to work it out manualy. Using prefabs seems a good idea, have you tried?

 bye,

 Jean

jalex19

  • Playmaker Newbie
  • *
  • Posts: 27
Re: Resetting a Game Object and its children within a scene
« Reply #2 on: April 07, 2012, 09:09:41 AM »
Thanks Jean

Investigating this additive level thing -
How do I assign game objects to a certain level? In this case, does "level" = "scene"? so I need to keep my level game objects in different scenes?  If so, does this affect global event transitions between objects in my base level and the individual levels?

 I am using prefabs, but not for my levels currently, since each one is unique, what did you have in mind for that?
« Last Edit: April 07, 2012, 09:19:45 AM by jalex19 »

jalex19

  • Playmaker Newbie
  • *
  • Posts: 27
Re: Resetting a Game Object and its children within a scene [Solved!]
« Reply #3 on: April 07, 2012, 03:36:35 PM »
Nevermind, I got it to work! Here's roughly what I did:

Made a scene with just the Level 1 Game Object in it +all the children (made it a prefab, see why below), Had the start state of the parent call Get Owner to a global variable called "Level 1"

In my Game Scene, I call this level by doing a Level Load Num Action, with additive. When I'm ready to destroy it, I Destroy Game Object and call the global variable "Level 1"

I also have a third scene called Level Editor, this is where I have all of the Level Game Objects loaded up, and I edit my levels there (because I really want to make my Level scenes devoid of any cameras or anything). Since I have each Level Game Object as a prefab, I can just update them in my Level Editor scene and they update automatically in my Game Scene.

Quite. Freaking. Cool.
Cool enough to distract me from PAX East :)