Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: DABYX on July 14, 2021, 02:10:17 AM

Title: Get FSM Usage (Solved)
Post by: DABYX on July 14, 2021, 02:10:17 AM
Hi all,

Complete beginner here and would like to say how great Playmaker is. I'm finally attempting something that I never had the confidence to do previously.  ;D

I have started making my first game which is pretty simplistic, (although probably could've made an even simpler one. I tend to go slightly overboard) and realised I have begun to use Get FSM Int and Get FSM State actions a lot.

This made me think about in the future if I ever try to make a more complicated game and if these actions use a lot of processing power? My ignorant guess is maybe yes so I thought I'd ask.

On the topic are there any actions that are best avoided in large quantities?
I know global variables can be tricky so I have avoided those so far.

Thanks.  :)
Title: Re: Get FSM Usage
Post by: Fat Pug Studio on July 14, 2021, 06:50:44 AM
I use get/set fsm in a production ready game to avoid using globals, literally thousands of times with no downsides, so fire away. It's sad that the globals are a mess so you need a few steps more, but at least it doesn't break.

Just avoid using stuff every frame if you really don't need to, that's about it.

Title: Re: Get FSM Usage
Post by: djaydino on July 14, 2021, 10:05:59 AM
Hi.
Get/Set Properties actions you should try to avoid as they are using reflection.

Always try to find dedicated actions, you can find a lot of custom actions on the Ecosystem (https://hutonggames.fogbugz.com/default.asp?W1181)

Create/Destroy = slow. so minimize using during gameplay

If you reuse the same prefab several times then you should look into pooling these objects instead of Create/Destroy
Title: Re: Get FSM Usage
Post by: DABYX on July 14, 2021, 12:23:36 PM
Thanks for the replies guys, appreciated!

That's good to hear Fat Pug Studios. I thought it would be fine this game but didn't want to get into a bad habit! Thanks.

I'm not sure I understand what reflection is djaydino. Could you eleborate?
I did actually know about pooling and destroying etc. I am currently using a lot of set/swap sprites atm which again, I imagine will be fine for this small project though.

Title: Re: Get FSM Usage
Post by: djaydino on July 15, 2021, 10:56:03 AM
Hi.
Reflection you can read about here :
https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/concepts/reflection

Basically the action accesses the fields/properties from a script.
which is slower that dedicated actions.
(this is also the reason that Bolt is slower than playmaker as it mostly does Reflection)
Normally you wont notice the difference when using a few and its mainly there to access 3rd party asset scripts that do not have Playmaker support.

But you can also have some issues when you build to certain platforms and you will then need to use Linker Wizard (http://hutonggames.com/playmakerforum/index.php?topic=11126.0) to make sure its included in the build
Title: Re: Get FSM Usage
Post by: DABYX on July 15, 2021, 01:02:13 PM
Brilliant. Thanks for all the info  ;D
I'll have a read up!
Title: Re: Get FSM Usage
Post by: Fat Pug Studio on July 16, 2021, 12:36:10 PM
Not only that, but using get/set properry by dragging and dropping stuff from inspector is prone to breaking references.

If you really need it, no need to write your own actions since it will be based on getting the component (caching) anyway. Just make an object variable, select it, then get/set property directly from that object. No risk of breaking, do it once when fsm starts up and you're good to go.
Title: Re: Get FSM Usage
Post by: DABYX on July 17, 2021, 06:23:27 AM
Now that's a good tip thanks!

Just to clarify as I'm a dummy, is this for get/set property only? As I've been using a lot of set sprites for now and again, bad habits and all.