playMaker

Author Topic: Are All PlayMaker Variables Global?  (Read 4784 times)

Psmith

  • Playmaker Newbie
  • *
  • Posts: 24
Are All PlayMaker Variables Global?
« on: June 13, 2011, 07:19:14 PM »
I'm not a programmer.  But, I do know that in programming languages there are ways to designate whether a variable (a container) is accessible to the entire program being written, or just to a given block of code.

In the PlayMaker documentation and in the examples, I can't see a way to differentiate between the two variable types.

Does this mean that all PlayMaker variables are accessible to all states?

Does a PlayMaker file or the entire FSM get written as a single block of code?

What kind of code does PlayMaker generate?

Thanks,


Psmith
« Last Edit: June 13, 2011, 07:23:44 PM by Psmith »

MaDDoX

  • 1.2 Beta
  • Full Member
  • *
  • Posts: 165
    • FluidPlay Studios
Re: Are All PlayMaker Variables Global?
« Reply #1 on: June 14, 2011, 12:17:23 AM »
Quote
all PlayMaker variables are accessible to all states?
Yes, but these are actually "local", in an FSM sense at least. A "global" variable would be seen by every FSM active in the scene, but there's no such thing currently, you need to set event data -> send an event or read/write the variable remotely - check the "read int" action I've posted for an example.

Quote
Does a PlayMaker file or the entire FSM get written as a single block of code?
Not really, the FSM data (whatever actions, variables and values you've set) is saved along the scene, probably as a metadata. Alex can clarify this further.

Quote
What kind of code does PlayMaker generate?
None, it's all interpreted in real-time. uScript on the other hand, generates C# code, but it lacks any sort of interactive debugging, which Playmaker is full of. Before you ask if this hurts performance, remember what's actually run are the actions, and those are C# scripts which take the simple FSM variables as parameters. Not saying there's no overhead by having a multitude of FSMs running at the same time, but you'd get bad performance out of a shitton of non-optimized C# scripts running at once as well.

If you ask me, what's really hard in Playmaker is understanding how multiple commands can be executed in the same logic frame, I think whatever is in the same state is run in a single logic frame. When you're trying to "code" a very complex behavior which requires time-critical execution it generally poses a problem, especially when it demands communication between FSMs.
--
Breno "MaDDoX" Azevedo
@brenoazevedo

Psmith

  • Playmaker Newbie
  • *
  • Posts: 24
Re: Are All PlayMaker Variables Global?
« Reply #2 on: June 14, 2011, 12:38:29 PM »
Thanks, Maddox.

I don't think I totally understand everything you have said - nor do I understand everything that is going on with state machines in PlayMaker.  This is because I have no background in programming, at all.

Maybe, for new people approaching the making of a game or game-like behaviours with PlayMaker - it is better not to have that background of knowledge, through which you have to filter all of those concepts which strictly belong to PlayMaker.

Since, I believe, PlayMaker is starting a very new and lasting paradigm for making this kind of thing, perhaps it will be a better thing to "start fresh" with our understanding of the way things work.

I know I'm making much more rapid progress in this area than I ever could, when trying to understand the ways of programming by means of code and the various forms of syntax each one requires.

I like the PlayMaker concept of doing everything in small "chunks" (I know this word is being used as a proprietary word in programming circles).  I like the idea that, although only one State is active at any given time, many Actions can be executing simultaneously - which, in turn, can be communicating (instantaneously) with other States.  This is deep stuff.  A different way of looking at things.  

At least I think I am seeing this correctly.


Psmith

artician

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 318
Re: Are All PlayMaker Variables Global?
« Reply #3 on: June 14, 2011, 01:49:17 PM »
I might be able to help.  It's easy for things to get out from under you, because this tool has made it so easy to plug things together without fully understanding what's going on.  Frustration is a frequent reward if you're in that position, because when it comes time to actually engineer an efficient, functioning system, you realize that something like PlayMaker can't help you with the discipline and theory.

Sorry for the redundancy, but I'll partially translate MaDDoX's reply. ;)

Quote
all PlayMaker variables are accessible to all states?
Yes, though you have specifically send or request this data between FSMs.  They are not "global" in the sense that a variable Int named "score" on one FSM is treated the same as another Int named "score" on another.  FSMs can have identically named variables without interfering with one another. Anything you store in one FSMs variable, can be grabbed out by another, separate FSM.  You can see the actions used for this as the "Send" or "Get" actions you see within the StateMachine action group within the editor.

Quote
What kind of code does PlayMaker generate?
None.  However it uses[/] whatever code or script its actions were initially written in, usually C#.  You can see this for yourself by looking at the .CS files in the Playmaker Actions subdirectory.

Quote
PlayMaker is starting a very new and lasting paradigm
It's actually not!  Though it's an extremely robust initial offering for Unity.  Tools like Motivate, Virtools Dev, Multimedia Fusion (to a lesser degree) and more recently Kismet (unreal engine) have been around for 5-15 years.  The coupling of such a usable interactive development environment (IDE) like Unity with it though has given it a very wide visibility that is new to it.  I get a good feeling from it too!

Quote
I like the PlayMaker concept of doing everything in small "chunks"...
Just in case you aren't familiar with it you may want to read up on http://en.wikipedia.org/wiki/Object_oriented_programming, as it's mostly what you're talking about when you describe the method of working with PlayMaker.  It's a simple concept to understand and goes a long way to helping you design efficient statemachines and systems.

Sorry for the redundancy again, but I hope that helped.
« Last Edit: June 14, 2011, 04:56:21 PM by artician »

Psmith

  • Playmaker Newbie
  • *
  • Posts: 24
Re: Are All PlayMaker Variables Global?
« Reply #4 on: June 14, 2011, 07:30:11 PM »
Artician:

Thanks for clarifying.

What I meant by a "new paradigm" is not just a friendly API, a graphical one - but the concept of using "state machines" for nearly everything you need in a "game".

To me, they are like robotic instructions given to robots on an assembly line:

1) When you see "Part 11798" - grab it - rotate it - place it here - insert bolt - turn bolt - add nut - broadcast "finished" event to robot on opposite side of car..

2) When you see "Part 2359854". (more instructions). . .
 

Number (1) is a single FSM with the actions "Grab", "Rotate", "Place", "Insert Bolt", "Turn Bolt", "Add Nut", "Broadcast (Finished)".  The Event that triggers state (1) is "When you see (Part 11798)".

Now, it seems that FSM (1) could just as easily be broken up into 7 separate, smaller state machines - each doing only one thing.  Determining when to break up 1 large FSM into smaller "Chunks", or FSMs is still a mystery to me.

And, in the case of a "game" FSM vs. a robotic set of instructions - game Actions can seem to occur simultaneously (even though they are executed in order), because of the speed of computer hardware - whereas a robot "lives" in a physical world constrained by the reality of real world forces - thus allowing someone to observe the execution of all the individual Actions happening sequentially.

It would help me to see more "game behaviours" described in terms of state machines.  A sequence of events that trigger actions directly by the "subject FSM" and indirectly by those FSMs that receive the "Broadcast" Event.


Psmith