playMaker

Author Topic: Save Score  (Read 6169 times)

Satrio

  • Junior Playmaker
  • **
  • Posts: 67
Save Score
« on: August 29, 2011, 01:59:47 AM »
Hi!

I want to load a new level, but need to save the score somewhere.

I have made a "scoremanager", but everything gets destroyed when i load a new level.

How would you go about something like this?

Also, how does the "dont destroy on load" work?

/s

Damian

  • 1.2 Beta
  • Full Member
  • *
  • Posts: 188
    • Permaximum Betty
Re: Save Score
« Reply #1 on: August 29, 2011, 01:06:48 PM »
Well you can do it many ways.
Use global variables.
Save to playerpref.
Save to a file and read them up in the new level

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Save Score
« Reply #2 on: August 30, 2011, 07:15:45 AM »
Hi,

 You should use DontDestroyOnLoad system. Flag a gameObject with this and it will persist between scene unloading and loading.

http://unity3d.com/support/documentation/ScriptReference/Object.DontDestroyOnLoad.html



Bye,

 Jean

Satrio

  • Junior Playmaker
  • **
  • Posts: 67
Re: Save Score
« Reply #3 on: August 30, 2011, 12:58:23 PM »
So that means the "score-manager" is flagged as dont-destroy, and thus is not included in the next level load.

But how do I make it so I can Playtest a Subsequent level without haveing Scoremanager present? I mean if it is initialized in level one, it is not present in level two, cause then I would have two scoremanagers and so on?

Has anyone built a scoresystem with Playmaker for more than a demo of one level?

@Damian: Didnt think global variables were possible in playmaker. But I like the idea of saving a file, but how do you go about this in playmaker?  Im no php guy, but a local save would suffice for me.

As a non-programmer Id like to get some more information on how to structure projects with playmaker.
There are many standard problems for games, and examples on how to handle them would be nice.

/s

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Save Score
« Reply #4 on: August 31, 2011, 01:57:10 PM »
Hi,

 If you want to test some subsequent level individually, you can either build a script that check this ( for example a singleton type of script or you simply disable it by default and enable it during your game play if you actually need it when testing that particular level.

The problem with "standard" things is that most of the time it turns out it isn't, very difficult to squeeze a feature down to a generic system making sense in a majority of situations.

A full featured working game would be indeed a very nice thing to have in the documentation. With the latest demo from Unity ( angry bots) it could be a very good thing to take all the assets and rebuild it in playmaker. That's something I have at the back of my mind to do when I'll get some free time ( unfortunately not in the short-medium term...), because such demo game must be good looking even if you are only looking for the structure and design pattern used.

 Bye,

 Jean

Satrio

  • Junior Playmaker
  • **
  • Posts: 67
Re: Save Score
« Reply #5 on: August 31, 2011, 03:36:53 PM »
Thanks! Yeah that makes sense.. As a 3D artist you cant really have one character that fits all slots in every game, It was stupid of me to think code was any different.

I imagine you just have to put your head against the wall and push until you get through.
Thats why it is called "work" and not "fun" ;)

Still there are some basic programming issues that could be clarified. Like in painting there is color and composition theory. Must be something similar for Coding? Or is all code always spaghetti?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Save Score
« Reply #6 on: September 01, 2011, 03:07:27 AM »
Hi,

 You are correct. Design Pattern do exists for code, but I am not in a position to give you rock solid advices on this. The only rule I found so far is that you should not be afraid to delete code ( in large amount) and start again once you found a new/better/improve way. My struggle has always been trying to stick with the original idea or design, and this is wrong. It might feel like a waiste of time when deadline get closer but infact it's just post poning the inevitable. So don't be afraid to dive in and along the way you'll see the light eventually :)

For playmaker. The best way to tackle this is to ask for a particular set like the saving score for example.

Have you succeeded in maintaining your score manager when loading new levels and found the way to test individual levels?


 Bye,

 Jean

Damian

  • 1.2 Beta
  • Full Member
  • *
  • Posts: 188
    • Permaximum Betty
Re: Save Score
« Reply #7 on: September 01, 2011, 12:45:48 PM »
Well for the code part I can easy say on a project I might have changed the code 4-5 times before its finished.
Why?
Its very simple.
You have no way to know from the start what you gonna do and what new ideas you get under the way.
Some code can be very good, but it dont fit 100% with things you have done later in the project.
Also you always seek a simpler way to do things.
Less code is better if the code can do the same.
Some time when I get projects from other I do read the code to learn what it does.
Many times you can replace a lot of code with a very few code lines.

This is a part that is wierd sometimes with playmaker.
In a real code I can do a thing with 3 lines of code.
In playmaker it take alot more state and values etc to make the same stuff.
But i would like the normal code an playmaker was more easy to talk to each others.

Satrio

  • Junior Playmaker
  • **
  • Posts: 67
Re: Save Score
« Reply #8 on: September 06, 2011, 04:25:22 AM »
No I havent really been working directly on my project for a week or two. I´ve been bouncing it around my head trying to visualize how to build it though.  I figured some stuff would become a lot easier to test and do once 1.2 of playmaker is out. I just figured out that a lot could be simplified with "global events" that I still dont really understand fully on how they work. The manual suggests its use, but only in a few lines of text.

I built a prototype "battle grid" for my game "Dungeon Memory" where you have to play memory for damage and loot as well as clearing the dungeon. This means a player can come out with no damage from an encounter with a monster or wizard, although you might forget where the tiles were in the "dungeon grid".

Also my game needs an inventory system where different items might give bonuses or negate some negative effects of tiles.

The game could be built without having to load a new level, but it becomes so much harder to design. I imagine different dungeon grids with different themed tiles, layout and backgrounds like "Mirkwood Forest", "Caverns of Chaos", "Tower of Evil" etc