playMaker

Author Topic: Do I do it right? Global variables and playmaker variables...  (Read 2095 times)

Guicole

  • Playmaker Newbie
  • *
  • Posts: 2
Do I do it right? Global variables and playmaker variables...
« on: August 23, 2014, 02:57:26 PM »
Hi,

I was wondering if I was actually doing it right when it comes to use variables with playmaker.

I have global variables in scripts on game objects.
To access them with playmaker, and use them, I have to do a "get property" and then store the value in a playmaker property.
If my FSM changed the value I then have to do a "set property" to the global variable.

Feels like it adds a step, instead of dealing directly with the global I have to get the value and use another "playmaker" variable.

Is there another way to use globals? Or do I do it right?


Thanks.

G. colomb

PS: also, if I change the game object name or variable name, it breaks the link from the FSM. And that's really painful...


jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Do I do it right? Global variables and playmaker variables...
« Reply #1 on: January 15, 2015, 02:12:40 AM »
Hi,

 yes this is the way to do it if you don't write some specific custom actions or scripts ( cause you can do it from your actual script as well).

also, I an confused by "Global". In c# there is no concept of Global, you have local, public, static. can you clarify or actuall give a snippet of that variable you want to access from PlayMaker?

 "storing" an external value into an Fsm Variable is necessary if you use PlayMaker as is. you could write a custom action that is specificall taylored to work with that external value without ever storing it in playmaker, but I strongly recommand you don't. Storing has no performance cost and actions should be seen as "lego" blocks, for reusability.

however, I did try few technics for very complex objects, not because I did not wanted to store thenm in PlayMaker, but because it was impossible, Namely XmlMaker. I have created a manager that stored xmlNodes in a dictionnary against a string acting as reference, and so within my set of xml actions I can refer to data using a simple string, so all the xml is stored outside playmaker in a very efficient way, and I access it all from within PlayMaker.

 If you are interested by this kind of technics, let me know, I can explain it in details.

 Bye,

 Jean

lkmad

  • Beta Group
  • Playmaker Newbie
  • *
  • Posts: 24
Re: Do I do it right? Global variables and playmaker variables...
« Reply #2 on: April 20, 2015, 12:02:04 PM »
I'm also interested! :)

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Do I do it right? Global variables and playmaker variables...
« Reply #3 on: April 20, 2015, 01:03:27 PM »
Good :)

also, I am still not sure what the original request from Guicole... so it may be off topic.

I have just [urlhttps://twitter.com/JeanAtPlayMaker/status/590139853964255232]released[/url] an advanced Sample on the Ecosystem.

This sample has two "views" or menu "pages", and it shows how you can organize your data and fsm so that everything is kept locally or within event's data.

study, this sample, and if it fits your expectation as to how to work with PlayMaker, let me know, else maybe you want something more oriented to Xml Maker?

 Bye,

 Jean