Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: mental.breakdance on January 22, 2013, 07:48:30 PM

Title: iterating over and modifying custom actions
Post by: mental.breakdance on January 22, 2013, 07:48:30 PM
Hi all,

Just a code question here, and how best to manipulate Actions from external code. On our team we have a couple of designers who are building FSMs and as a programmer, I can just facilitate them by adding new Actions when needed. A rather nice arrangement so far! :)

However, as some of these new actions have dependencies on some of our systems, I'm looking into ways of setting the required data/pointers/etc on the actions via code, so that the designers don't have to drag a bunch of random game objects onto the action every time they use them. I'd like to avoid the use of singletons and just have their dependencies set externally if possible (i.e. dependency injection).

As such, would it be considered misuse of PlayMaker to do the following in a 'manager' class:


Obviously it's a very expensive call, but it would only be called once on initialisation. I'd be interested to hear if anyone else has done something similar or has a better idea on how to do it.

Thanks!
Title: Re: iterating over and modifying custom actions
Post by: mental.breakdance on January 23, 2013, 10:33:44 PM
One problem that I've found is that this doesn't work if the fsm is on a game object that is deactivated - at that point I can access all the FsmStates on it, but trying to access the FsmStateActions on that returns an error because the State is not initialized.

Is there any way of registering with an 'OnInitialized' event (or equivalent) on an fsm?
Title: Re: iterating over and modifying custom actions
Post by: jeanfabre on January 24, 2013, 08:24:52 AM
Hi,

What I would used instead is some static variables or methods that you define in your various scripts, and then you can can access them within your playmaker actions easily.

 Remember that within an action, you have a pointer to the gameObject of this fsm component, and you can simply get any other components attached on that gameObject, and thus you are within the very same environment as any other non playmaker scripts.

does that make sense?


bye,

 Jean