playMaker

Author Topic: How to create 'singletons' with Playmaker [SOLVED]  (Read 1241 times)

ItzArranT

  • Playmaker Newbie
  • *
  • Posts: 45
    • View Profile
How to create 'singletons' with Playmaker [SOLVED]
« on: June 24, 2017, 03:41:55 AM »
Hello again everyone,

This is a somewhat high-level question which I'll try to make as precise as possible.

I want to create a 'Level Manager' which handles Player moves per level and allows for the Player (via UI or level completion) to move between levels, as well as save level completion status.

Could anyone give any advice on how best to proceed?

I guess what I'm asking is are there any best practices surrounding an FSM which should link to a number of different scenes (levels).

Or, more to the point, is the best way to create different levels to use different scenes?

EDIT: To my mind, loading new scenes as a new level doesn't seem correct, since every scene would therefore contain its own Game Manager, Level Manager etc, which could potentially cause problems?

Thanks!
« Last Edit: June 29, 2017, 04:25:54 PM by ItzArranT »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 4615
    • View Profile
    • jinxtergames
Re: Creating a 'Cut the Rope'-style 'Level Manager'
« Reply #1 on: June 24, 2017, 08:23:35 AM »
Hi,
Quote
EDIT: To my mind, loading new scenes as a new level doesn't seem correct, since every scene would therefore contain its own Game Manager, Level Manager etc, which could potentially cause problems?

That depends on how you set this up, it can work fine.

But, there are other ways that you can use, for example :

"Don't Destroy on Load" and drop in the object that you don't want to be destroyed

Another way you can use is "load level" and set it to 'Additive'.
This will load what's in the scene but not destroying the current scene.

But i noticed that there is no unload action, i will try to make one this week.
please bump by friday if i did not reply yet :)

ItzArranT

  • Playmaker Newbie
  • *
  • Posts: 45
    • View Profile
Re: Creating a 'Cut the Rope'-style 'Level Manager'
« Reply #2 on: June 25, 2017, 05:16:46 AM »
That would be brilliant! Thanks djaydino :)

I'm also starting to think about how saving a level's "completed" status might work in Playmaker, but I'll open another forum topic for it, if needed.

elusiven

  • Full Member
  • ***
  • Posts: 233
  • Debt we all must pay...
    • View Profile
Re: Creating a 'Cut the Rope'-style 'Level Manager'
« Reply #3 on: June 27, 2017, 01:53:23 AM »
Singletons my friend. For things that manage stuff like controllers, managers etc it's a must pretty much to make it a singleton, what that means is that there will be only one instance of that script/object active at all times.

For saving stuff like progress you can use player prefs, xml or json, and if you don't want to handle it all by yourself then buy something like Easy Save 2, it includes encryption too, so your values will be harder to hack.
« Last Edit: June 27, 2017, 01:55:35 AM by elusiven »

ItzArranT

  • Playmaker Newbie
  • *
  • Posts: 45
    • View Profile
Re: Creating a 'Cut the Rope'-style 'Level Manager'
« Reply #4 on: June 28, 2017, 02:52:30 AM »
Hi elusiven, thanks for getting involved and the helpful advice.

I've already bought Mad Level Manager for level saving (didn't want to handle it all by myself!) however I'm very intrigued by 'singletons'- not a term I'm familiar with. Although it sounds like what I'm wanting to create.

Could you tell me how I go about making something a singleton?

Many thanks

ItzArranT

  • Playmaker Newbie
  • *
  • Posts: 45
    • View Profile
Re: How to create 'singletons' with Playmaker
« Reply #5 on: June 29, 2017, 04:21:08 PM »
bump

ItzArranT

  • Playmaker Newbie
  • *
  • Posts: 45
    • View Profile
Re: How to create 'singletons' with Playmaker
« Reply #6 on: June 29, 2017, 04:25:36 PM »
Just discovered Jean's superb 'Singleton Manager' action on the Ecosystem which answered all my problems perfectly.

Thanks again all!