playMaker

Author Topic: Best Practices  (Read 1964 times)

mathius777

  • Playmaker Newbie
  • *
  • Posts: 38
Best Practices
« on: January 09, 2015, 12:23:33 AM »
I have been trying to learn best practices with PM and had a few questions.

Globals: Is there a way to reduce the amount of global variables one uses? It seems that my global variable list becomes bloated very quickly and it becomes extremely hard to manage all of them. I was hoping there was some way to reduce them.

State-To-State Communication: It seems to be tedious to pass information between states easily, and I was hoping perhaps there was some cleaner way to do this that would reduce complexity.

And if anyone had any general resources they could point me to that would be awesome. I have a traditional programming background and keeping things modular and clean is important to me, and I really hate the feeling when things become too disorganized and I can't easily remember where some functionality exists. Thanks

mweyna

  • Full Member
  • ***
  • Posts: 242
Re: Best Practices
« Reply #1 on: January 09, 2015, 02:14:42 AM »
I know for my project I tend to create a lot of variable manager FSMs. So a game object with an FSM that just contains all my XXX variables. Then when I need to reference them I just point to that FSM rather then using a global variable.

mathius777

  • Playmaker Newbie
  • *
  • Posts: 38
Re: Best Practices
« Reply #2 on: January 09, 2015, 05:52:57 AM »
Interesting. I'll have to try that. Isn't constantly communicating with the module tedious though? I'd really love to hear some advice on inter-state communication and see if anyone has any clean designs they have come across while working with PM. Thanks.

mweyna

  • Full Member
  • ***
  • Posts: 242
Re: Best Practices
« Reply #3 on: January 09, 2015, 03:08:39 PM »
At least for me, it isn't nearly every frame that I need to pull a variable, normally just at the start of an FSM. So for instance my "How many of these do I have FSM" would check with my variable manager on start, then have all the logic after. If something changes that I need to see how many I have, then I just go back to the start of that action.