playMaker

Author Topic: Actions executing Out of Order  (Read 1224 times)

Luceid

  • Playmaker Newbie
  • *
  • Posts: 16
Actions executing Out of Order
« on: July 25, 2023, 06:57:05 PM »
Hello,
I noticed when trying to debug my control sticks that an action that should not have been executed after a transition was triggered, was triggered anyway. The setup is as follows:

"Idle": Checks both axes of control stick 1, writes values to floats, writes floats to a vector, then gets vector length. Transitions to "Pushed" when vector length >= 0.5

"Pushed:" Does the same as above, but transitions back to idle when axis vector length is < 0.5. AFTER this transition is checked, it writes the value of the axis vector and length to a new test vector and test length.

Therefore in theory, the test vector and length, should never be written to below 0.5 in length. However, rapidly flicking the control stick oscillates the test vector and length basically the same as the axis vector, even though the test vector should stop being written to after the state transitions back to idle.

I have included a basic sample scene on a brand new project in Unity 2022.3.5 and playmaker 1.9.7 to show my setup. I apologize if this is not a bug, but instead a misunderstanding on my part. But this page:
https://hutonggames.fogbugz.com/default.asp?W174
Leads me to believe that an action should never be run if a transition has been triggered above it.

Thank you,
-Luceid
« Last Edit: July 26, 2023, 02:06:38 PM by Luceid »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Actions executing Out of Order
« Reply #1 on: July 26, 2023, 12:55:03 PM »
Unity 2023.3.5 is this alpha version?

Luceid

  • Playmaker Newbie
  • *
  • Posts: 16
Re: Actions executing Out of Order
« Reply #2 on: July 26, 2023, 02:06:04 PM »
Apologies, that's a typo, this is on 2022.3.5. I originally noticed the potential bug on 2022.3.0 and upgraded hoping it might randomly solve the issue, but it did not.
« Last Edit: July 26, 2023, 02:08:00 PM by Luceid »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Actions executing Out of Order
« Reply #3 on: July 28, 2023, 08:12:53 AM »
Ok,
It's best to show some images of your fsm setup

Luceid

  • Playmaker Newbie
  • *
  • Posts: 16
Re: Actions executing Out of Order
« Reply #4 on: July 28, 2023, 08:18:10 AM »
Good morning,

I tried another much simpler test with only a button and two bools to try and weed out any potential interference, and this potential bug was still replicated quite easily. All actions are checked every frame. All button checks use the get key action.

State 1 "Not Pressed": Checks the value of the spacebar key, and writes to a bool variable called space. Then does a bool test, and if true sends to the pressed state.

State 2 "Pressed": Checks the spacebar key and writes to the same space bool, and performs another bool test, sending back to not pressed if the bool is false. After the bool test, writes the value of space to another bool called spaceTest.

As with my previous control stick setup, despite the fact that spaceTest should not be written to after space turns to false and triggers the transition above it, it still does.

However I tried an interesting twist after that. I made it so that the tested variable has absolutely nothing to do with any other button or player input, I only use the spacebar key to trigger the transition.

State 1 is same as previous setup.
State 2 now sets a "check" bool to false before the space bool test, then sets check to true after the bool test. If spacebar is held, it correctly shows check as being true, since that is its last value each frame. However when spacebar is let go, and the fsm transitions back to not pressed, the check bool still shows true, despite the fact that it was written false before the bool test, and should only be written true after the transition is checked and failed.

I apologize if this is a bit confusing, but I have again attached a new sample scene to demonstrate the issue I am having. It really feels like I am potentially misunderstanding a basic premise of playmaker, so if this is not a bug, I would really appreciate any insight into what is going on here. I just can't reconcile the note on the action page linked above with what I see in my tests:
IMPORTANT: If an Action triggers a transition, the transition happens immediately and the Actions below it are not executed.

Thank you,
-Luceid
« Last Edit: July 28, 2023, 08:22:45 AM by Luceid »

Luceid

  • Playmaker Newbie
  • *
  • Posts: 16
Re: Actions executing Out of Order
« Reply #5 on: July 28, 2023, 08:19:21 AM »
Ok,
It's best to show some images of your fsm setup

Sorry, I was writing my above post before I saw your reply, I'll attach some images momentarily! Both tests share the same state 1 so I only included it once.
« Last Edit: July 28, 2023, 08:25:18 AM by Luceid »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Actions executing Out of Order
« Reply #6 on: July 30, 2023, 02:56:15 PM »
Hi.
In 'Pressed' you are setting a bool true and false at the same time.

Execute order will start executing in order, but they do not necessary finish in order.

solution is simple, move 1 of the Set bool value in the 'Not Pressed' state.
Also there is no need to do them every frame.

Another thing is :
You could use Get Key Down/UP instead of Get Key + Bool Test

You can set a state to Run in sequence (which will make each state wait till it is finished before going to the next one) , but you can't use every frame (except for the last action on the bottom of the list)
To do so right click on a empty space in the state window and select Action Sequence.

Luceid

  • Playmaker Newbie
  • *
  • Posts: 16
Re: Actions executing Out of Order
« Reply #7 on: July 31, 2023, 08:41:55 AM »
Hi.
In 'Pressed' you are setting a bool true and false at the same time.

Execute order will start executing in order, but they do not necessary finish in order.

solution is simple, move 1 of the Set bool value in the 'Not Pressed' state.
Also there is no need to do them every frame.

Another thing is :
You could use Get Key Down/UP instead of Get Key + Bool Test

You can set a state to Run in sequence (which will make each state wait till it is finished before going to the next one) , but you can't use every frame (except for the last action on the bottom of the list)
To do so right click on a empty space in the state window and select Action Sequence.

Thank you for the response DJAY.

This fsm was set up purely to illustrate an issue I was having in my real project.

I have already worked around it by doing something similar to what you suggested. I moved some of my logic to a different state, that operated on a next frame logic.

I was more concerned with why it was behaving the way it does. Why does an action still fire off after a transition triggers above it? I'd like to understand the how a situation like this happens so I can avoid accidentally creating behavior like this in the future. You hinted at the timing of events firing and finishing being different but I'd like to know a bit more if you don't mind.

Thank you,
-Luceid

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Actions executing Out of Order
« Reply #8 on: August 02, 2023, 08:05:36 AM »
Hi.
in your setup for example :

Get get action started 1st.
then Set Bool Value Gets start.
and so on.

but if Get Key takes longer to Finish
the other actions might already have finished.

so if the Get key result would be true it might have been setting the value 'After' the bool was tested.

for the 2 set bool values if you would is a Get Fsm Bool from another fsm (you might get mixed results as you are setting the bool to true and false within the same frame.

so then it depends on when the "Get Fsm Bool" is called within that frame.