playMaker

Author Topic: Call an action (not on game object) from a non-FSM script?[SOLVED]  (Read 2194 times)

amaranth

  • Full Member
  • ***
  • Posts: 172
Is there a way to call an action that isn't on a game object?

Here's my problem:
-I have 1000 creatures with different behaviors.
-1000 FSMs kills my game performance (even when disabled), so I believe I need to avoid them for the creatures.
-Having all 1000 creatures use the same FSM on a game monitor GO won't work because it's possible one creature will call the FSM before the FSM is finished for another creature.

Here's what I'm trying to do:
-I have an action called MorphCreature.
-I use this in an FSM on my game monitor GO.
-I'd like to use the same MorphCreature action in the C# script I've attached to each creature. Goal is not to duplicate code.

So if you had a non-FSM script and you wanted to reference an FSM action script, how would you do this?

Thanks for any help!
« Last Edit: October 23, 2012, 03:21:58 AM by jeanfabre »

DARK_ETERNAL

  • Full Member
  • ***
  • Posts: 110
Re: Call an action (not on game object) from a non-FSM script?
« Reply #1 on: October 22, 2012, 06:26:49 PM »
You don't need to have every monster to send nothing to a manager FSM, if I got your issue correctly. Or, wait... Exactly, what does this MorphCreature action do? Does it somehow change your monsters (as the name would suggest)?

Now, to call a function from a custom script, you might want to use 'Invoke Method' action, although you would have to specify which GO has the script where the function you want to call is (I'd think is your monitor). If you, by the contrary, want to have a reference for an FSM, declare a public PlayMakerFSM variable in your script, so you can drag&drop the object containing that FSM to the inspector. You would have access to variables, events, and such data.

Hope this helps.
Check out our new game: Nitro Chimp. Now live in App Store!

Trailer:
Download: https://itunes.apple.com/app/nitro-chimp/id557150450?l=en&mt=8

amaranth

  • Full Member
  • ***
  • Posts: 172
Re: Call an action (not on game object) from a non-FSM script?
« Reply #2 on: October 22, 2012, 11:01:29 PM »
Ended up just doing this:
http://hutonggames.com/playmakerforum/index.php?topic=2429.0

Thanks for your help!