playMaker

Author Topic: Disable and enable FSM performance question  (Read 1894 times)

Sly

  • Full Member
  • ***
  • Posts: 127
Disable and enable FSM performance question
« on: June 01, 2022, 03:40:55 PM »
Hi there,

I was wondering if it's worth it to deactivate FSM during my gameplay. Is it heavy on performance to deactivate and then resume later, compare to put my fsm in an empty state and wait?

To explain my situation, I'm am trying to optimize my AI. Every AI far from camera will deactivate their fsm and resume (It's a top down view).

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7618
    • jinxtergames
Re: Disable and enable FSM performance question
« Reply #1 on: June 02, 2022, 10:16:45 AM »
Hi.
I don't think its 'Heavy' on performance.
But i could create some garbage depending on the actions you use.

But if you use 2019.3+ then there is no need to worry at all for it (with updated garbage collection system)

Sly

  • Full Member
  • ***
  • Posts: 127
Re: Disable and enable FSM performance question
« Reply #2 on: June 02, 2022, 11:05:54 AM »
I'm actually using the EnableFsm action included into Playmaker.

The thing is my AI radar Disable the AIController FSM when camera is too far. It's possible to have 50 to 80 Character on the entire Map (Normally I would guess 20 could potentially activate/deactivate in same time)

Maybe I could create a custom EnableFsm action to store the Fsm in a variable instead of getting the component each time I need it.

I'm still not using 2019.3 or more, but it's honestly a good way to convince myself to switch to it :)

Sly

  • Full Member
  • ***
  • Posts: 127
Re: Disable and enable FSM performance question
« Reply #3 on: June 02, 2022, 11:50:36 AM »
I have made a custom action for it.
Basically, The Fsm returned the first time will be stored into a variable. So the next time the action is called, it doesn't need to search for the correct FSM. It already has the reference of it.

I'm sharing the action here for people who will need it. :)

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7618
    • jinxtergames
Re: Disable and enable FSM performance question
« Reply #4 on: June 02, 2022, 01:37:49 PM »
Hi.
Yeah... our project is also still on 2018 LTS

But we can see garbage issues (Lag Spikes) so we probably gonna update to 2019
as it will take a lot of time to cleanup to reduce garbage.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7618
    • jinxtergames
Re: Disable and enable FSM performance question
« Reply #5 on: June 02, 2022, 02:28:31 PM »
HI.
I use The component directly (where possible)

Here's the action i use

Sly

  • Full Member
  • ***
  • Posts: 127
Re: Disable and enable FSM performance question
« Reply #6 on: June 06, 2022, 07:51:36 AM »
Thanks for the Action!

In my case I have garbage collector issue but I don't think it's because of Playmaker but more about the amount of object/characters. That's why I try to optimize my stuff. Reducing GetComponent call as much as I can help a lot.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7618
    • jinxtergames
Re: Disable and enable FSM performance question
« Reply #7 on: June 06, 2022, 10:01:17 AM »
Hi.
yes its not playmaker, but there are several actions/custom actions that are not optimal. (official actions might be updated by now, but our project is still using PM 1.9.0)
for example using GetComponent on update.

also we reduced trigger events a lot and use overlap action.

or for example, we had shards that player can pick up and the shards would have a trigger event.
now the shards have no trigger event any more and we have a overlap that checks every 4 frames for shards.