playMaker

Author Topic: Fsm Template  (Read 255 times)

ch1ky3n

  • Full Member
  • ***
  • Posts: 185
    • View Profile
Fsm Template
« on: March 04, 2021, 03:37:38 PM »
Not sure if this is a bug or intended
basically,

1. I made a template which is only "Float Add value A + Value B", where value B is exposed as an Input Variable

2. Then I delete it and use it in Run Fsm,

3. On Fsm Action, I have to put a value on the exposed Value B.

4. It works if I put a direct value on it. It is also worked if I enter the variable value beforehand.

5. However, When I eased a variable from 0-10, it will stays 0 and if I put ease float 5-10 it will stays 5.

6. Did a couple of tests with add value, set fsm float, but it won't change, so it can't be changed once the fsm template is running. It only accepts the initial value of the variable before running the fsm.

Hope someone can confirm if this is the case.

PS: I try with or without everyframe both on the template and FSM that run the template and no luck


« Last Edit: March 06, 2021, 11:15:54 AM by ch1ky3n »

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3893
  • Official Playmaker Support
    • View Profile
    • LinkedIn
Re: Fsm Template
« Reply #1 on: March 04, 2021, 05:42:12 PM »
Hi, right now this is working as intended - the input values are injected once when entering the action. However, I am playing with the idea that input values would update if every frame is checked. It will probably be in the next beta build to see how it works.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 6003
    • View Profile
    • jinxtergames
Re: Fsm Template
« Reply #2 on: March 04, 2021, 06:08:06 PM »
Hi.
Yeah, having the ability to input/output every frame optional would make it a lot more powerful.

I use a lot of templates/run fsm in our project (but still on PM 1.9.0)
and i use Get/Set Fsm and other fsm actions to make it work every frame.

ch1ky3n

  • Full Member
  • ***
  • Posts: 185
    • View Profile
Re: Fsm Template
« Reply #3 on: March 05, 2021, 12:01:25 AM »
OK got it,

It should be insanely powerful if it can update every frame.

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3893
  • Official Playmaker Support
    • View Profile
    • LinkedIn
Re: Fsm Template <SOLVED>
« Reply #4 on: March 05, 2021, 01:51:10 PM »
Give the attached action a go. It updates inputs every frame, but the implementation might change before the next official release. Treat it as a beta :)

There are a couple of concepts I'd like to make clearer in RunFSM and would love feedback on:

- Every Frame really means restart when finished. I tried to re-use the Every Frame concept from other actions, but I think this was a mistake. It should probably be labelled "Restart FSM When Finished". What do you think?

- Do we need options for "Update Inputs Every Frame" and "Update Outputs Every Frame" or is that just expected behavior? Are there situations where you don't want to update inputs/outputs every frame? There is a small performance benefit to not updating inputs if you know they're not changing...

 

ch1ky3n

  • Full Member
  • ***
  • Posts: 185
    • View Profile
Re: Fsm Template
« Reply #5 on: March 06, 2021, 11:46:54 AM »
That's weird, I tried the new runFsm and the template is disabling itself after entering play-mode regardless of whether everyframe or !everyframe.
mY action is just float operator of moveRight - moveLeft = result
(The value doesn't change too)

throw nullRefException:

Code: [Select]
NullReferenceException: Object reference not set to an instance of an object
HutongGames.PlayMaker.FsmTemplateControl.UpdateInputs () (at C:/Projects/Playmaker_1.9.1/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/CustomActionTypes/FsmTemplateControl.cs:259)
HutongGames.PlayMaker.Actions.RunFSM_New.OnEnter () (at Assets/PlayMaker/Actions/StateMachine/RunFSM_New.cs:67)
HutongGames.PlayMaker.FsmState.ActivateActions (System.Int32 startIndex) (at C:/Projects/Playmaker_1.9.1/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/FsmState.cs:222)
HutongGames.PlayMaker.FsmState.OnEnter () (at C:/Projects/Playmaker_1.9.1/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/FsmState.cs:192)
HutongGames.PlayMaker.Fsm.EnterState (HutongGames.PlayMaker.FsmState state) (at C:/Projects/Playmaker_1.9.1/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/Fsm.cs:3070)
HutongGames.PlayMaker.Fsm.SwitchState (HutongGames.PlayMaker.FsmState toState) (at C:/Projects/Playmaker_1.9.1/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/Fsm.cs:3009)
HutongGames.PlayMaker.Fsm.UpdateStateChanges () (at C:/Projects/Playmaker_1.9.1/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/Fsm.cs:2942)
HutongGames.PlayMaker.Fsm.Start () (at C:/Projects/Playmaker_1.9.1/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/Fsm.cs:2166)
PlayMakerFSM.Start () (at C:/Projects/Playmaker_1.9.1/Projects/Playmaker.source.unity/Assets/PlayMaker/PlayMakerFSM.cs:591)

Quote
There are a couple of concepts I'd like to make clearer in RunFSM and would love feedback on:

- Every Frame really means restart when finished. I tried to re-use the Every Frame concept from other actions, but I think this was a mistake. It should probably be labelled "Restart FSM When Finished". What do you think?

- Do we need options for "Update Inputs Every Frame" and "Update Outputs Every Frame" or is that just expected behavior? Are there situations where you don't want to update inputs/outputs every frame? There is a small performance benefit to not updating inputs if you know they're not changing...

For me, I treat template like a collapsed version of the many states inside it, so if the states was designed to return to the state 1, then the template will run forever. But maybe i was wrong about the template general concept.
« Last Edit: March 06, 2021, 11:53:55 AM by ch1ky3n »

Gustav

  • Junior Playmaker
  • **
  • Posts: 53
    • View Profile
    • Pyrit Soft
Re: Fsm Template <SOLVED>
« Reply #6 on: March 07, 2021, 03:49:12 PM »
- Every Frame really means restart when finished. I tried to re-use the Every Frame concept from other actions, but I think this was a mistake. It should probably be labelled "Restart FSM When Finished". What do you think?
I agree, "Restart FSM When Finished" would be the better choice. Because it's so unusual that Templates run in parallel in a state machine I always thought the state actions were paused until the Template finishes. I can imagine that a lot of users think that way in the first place. Therefore it would be great if the tooltip of this option could contain a little hint like "The Template/FSM runs in parallel to the current state".

Quote
- Do we need options for "Update Inputs Every Frame" and "Update Outputs Every Frame" or is that just expected behavior? Are there situations where you don't want to update inputs/outputs every frame? There is a small performance benefit to not updating inputs if you know they're not changing...
Due to the fact that Templates run in parallel to the current state, to me they feel like their own states. And different states in the same state machine don't communicate with each other during execution because only one state is active at a time. Because of that I think by default Templates should get Input variables only at start and Output variables only after finishing. But I can imagine in some use cases it would be useful to get these values every frame. Therefore I think it would be the best solution to offer "Update Inputs Every Frame" and "Update Outputs Every Frame" options.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 6003
    • View Profile
    • jinxtergames
Re: Fsm Template
« Reply #7 on: March 07, 2021, 05:38:18 PM »
Hi.
In our game, our enemy AI's uses several run fsms.
for example the patrol state on some enemies would use several run fms's

for example one for patrol (walking left right)
one for wall/floor detection (which uses 'Set Fsm Bool' now, the set a bool on the parent.

Patrol is using a 'Fsm Bool Test' to see if a wall was hit or if there's no floor.
I also have several attack that also uses the wall/floor detections.

in this case it would be easier to have output updating, then there would be no need to use set fsm bool.

maybe a possibility to have update on value changed would be more interesting then just every frame.
i don't know if that would make a difference in performance tho