NodeCanvas Forums › Support › the Dynamic feature with Event trigger
hi, dear develop team
I am testing the behavior tree dynamic feature to hook with my own event in the project. to simplify this question, I used a check-input task and a check boolean task to descript the issue.
I connect the node as pic showed, A and B are 2 methods pattern to test in turn, and the sequencer always set as dynamic
[Please ignore the repeat pic in attachment, I don’t know how to delete it ]
when I play pattern A, the thing runs ideally as I imaged, if I set the value is None, it will goes through the node, and if I change the value at any time, the flow will break and re-play from the condition node again
but once I replaced the conditional task to check button, it is changed. when I pressed down the button, it will trigger the flow to the next node but very soon, the running flow is broken and stop quickly
I am guessing when I pressed the button, the check button condition becomes true and the tree runs into the next step, but soon in the second runtime update, I released the button and the condition node immediately checked as false, so it triggered the dynamic sequencer to abort the running again, which make the whole tree abort twice.
if my guessing is correct, then it means the event actually triggered twice. the first is real firing, then the second time is the state changed
I am just wondering how to make the event /check button acts as a normal one time triggering event like scripting in class.
Hello there!
Your explanation generally correct, yes 🙂 Since the condition “If Down Space” is evaluating to TRUE for only one frame, the exact next frame where it evaluates to FALSE, the Dynamic Sequencer is interrupted as it should (since it is Dynamic).
When you want to make something like a “one time trigger”, based on a condition that only temporarily (like a keystroke) returns TRUE, then you should really not use the Dynamic option in that case 🙂
Also, please remember, that the option “DOWN” is evaluating to true only for one and in that same frame that the key has been hit down. On the other hand, you can also use the “PRESSED” option, which evaluates to true, for as long as, the key is held down.
Let me know if that works for you.
Thanks!
Join us on Discord: https://discord.gg/97q2Rjh
hi, Gavalakis
thanks for the reply,I think I used the button down checking, so however I keep pressing or release, the event only can be checked once , but it triggered the dynamic system 2 times. Using button check condition is just to test the dynamic abort function simply, the final purpose is that I am going to use event receive task to trigger a sequence actions ,I guess it will work same as the button-check, which means at the second frame the event receive state will change back to false and trigger the abort again.
I have a rough idea to write my own event receive task and convert it to a boolean check task inside, so the Dynamic function only can be triggered when the boolean value changed by the event, and it will not change the state at the second frame when the event state becomes false again. it is similar to you suggested me to use pressing down check task to replace the button down task 🙂
Before I start to implement that way, do you have anyother suggestions? I saw some people use parallel node to run the event-check conditional task as a parallel child, which looks like a Polling method. I don’t know how is the performance, but it makes the tree more complex. if the BT Dynamic system has an option that only monitors the returned value as True or has a better event -check a task that only trigger once , then everything looks cleaner and easier to be understood.
thanks
Hello again,
Thank you for the extra info. To be completely honest, I am not sure exactly what you want to achieve yet 🙂
The Keyboard Key Down condition, returns true the same frame the key is pressed and all next frames it returns false, since the key is no longer pressed. That means that in this case you need to use the Keyboard Key Pressed condition, if you want the condition to return true as long as the key is pressed/held down.
On the other hand, you can simply not use the “Dynamic” option, if you want the condition to be evaluated only once, which I think is what you want here?
But, I am sure I am missing something though (?)
Please let me know if so 🙂
Thanks!
Join us on Discord: https://discord.gg/97q2Rjh