I want to implement a behaviour where I have to wait for an input touch event and then my character moves to that input touch event position. However, while the character is moving, when I press and execute a touch input event again it stops the moving character and moves to the new target position. How do you do that?
I have implemented the a conditional node that listens to the touch event and moves the character, but my problem is I don’t know how to do the latter.
One way would be using a Parallel node and a Repeater like the image I’ve attached for you, but probably the best way, would be if you handle all this self-contained in a custom action task, which both checks for touch in it’s execute as well as in it’s update. If in it’s Execute there is no touch, it simply returns failure (with EndAction(false) ). Here is an example:
It didn’t work for me. But, I found a solution that worked well. Thanks for the suggestion it gave me a better understanding of how the behaviour tree works.
I have an additional question though, what’s the proper way of subscribing and unsubscribing to events in Conditional Nodes? Is this right? Is it the same in Action nodes?
Glad you found a proper solution for your case and thanks for sharing.
Regarding subscribing/unsubscribing for conditions, right now, OnEnable and OnDisable is only called for conditions in FSMs, since in Behaviour Trees, there is no clear moment where a condition is enabled or disabled apart from when the BT starts and ends.
So the best candicate for subscribing, would be OnInit, and you can use OnDisable for unsubscribing for within an FSM context.
I will make OnEnable and OnDisable be called for BTs when they start and finish as well, in the next version. Added this in the TODO list.
So prety much what you have is correct right now.
As far as actions, you can once again use OnInit for subscribing and OnStop for unsubscribing if that is something needed.
Again, I will improve the API to be more consistent between both action/condition tasks and amongst all graphs regarding enabling/disablng in the next version.
Thanks!
Join us on Discord: https://discord.gg/97q2Rjh
Author
Posts
Viewing 5 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic.
Login
Register
By registering on this website you agree to our Privacy Policy.