playMaker

Author Topic: Performance wise, is it better to Send FSM info or Get FSM info when moving info  (Read 1937 times)

paradiseprime

  • Full Member
  • ***
  • Posts: 106
What I mean is for something like getting the input of a raycast that is always on getting the surface normal of a wall. Is it better performance wise to send that info out every frame or to have it called by the state that needs that info? It sounds obvious but I feel it might be a case by case thing.

For something like a button press, do I want to send the info of the button or get it?

Maybe I am over thinking this and the answer is simple.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7618
    • jinxtergames
Hi.
In this case its probably better to get the data from a other fsm as you might want to use it in different fsms.
Performance wise there should not by any noticeable difference.

Something else you can look into is if you can get away by doing this every other frame or every 10 frames for example.
This can help in performance.


Broken Stylus

  • Beta Group
  • Hero Member
  • *
  • Posts: 824
Do you tie the info to an event?

paradiseprime

  • Full Member
  • ***
  • Posts: 106
Do you tie the info to an event?

Can you explain that more?

paradiseprime

  • Full Member
  • ***
  • Posts: 106
Hi.
In this case its probably better to get the data from a other fsm as you might want to use it in different fsms.
Performance wise there should not by any noticeable difference.

Something else you can look into is if you can get away by doing this every other frame or every 10 frames for example.
This can help in performance.

How do you determine how many frames to wait?

Broken Stylus

  • Beta Group
  • Hero Member
  • *
  • Posts: 824
Can you explain that more?

Yes, you can attach data to an event you send. Right before the Send Event action (and variants), use the Set Event Data, it will automatically associate variables to the next event sent from this FSM, packing them as the event is sent (it's like a form of encapsulation).
Then you just have to collect the data on the receiving end with an action called Get Event Info right where another FSM's state receives the event. There are actions that are specific to var types like Get Event Int Data, another one for strings but I might have taken them from the Ecosystem.

You can also use Set/Get Event Properties that requires extra steps, wherein a property is defined with a key (a string used for the property's name), a var type (Float, Int, String, etc.), and the actual value or FsmVariable to use.
This can be useful if for some reason some events might fail to receive data.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7618
    • jinxtergames
Hi.
Determine how many frames to wait is totally depending on your game.

Enemies could for example do a raycast to look for player every x frames instead of every frame.


Broken Stylus

  • Beta Group
  • Hero Member
  • *
  • Posts: 824
There's a recent action that's called Send Event Frame Delay, it lets you send an event with a delay in frames, not seconds. It's on the Ecosystem.