Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰 fix interrupt of sequence star/random + improve docs #249

Merged
merged 4 commits into from
Nov 17, 2023

Conversation

bitbrain
Copy link
Owner

Description

Usually, any sequence node that fails should correctly interrupt its running children, if there are any. This worked correctly for sequence and reactive sequence but not for sequence star nor sequence random.

Also addressed docs, which hopefully closes #248

@@ -18,10 +18,12 @@ With composite nodes, you can craft unique and dynamic Behavior Trees for your g

## Restarting a composite

If a parent node restarts a child node, it means that the parent node will start the child node from scratch the next time it is ticked. This means that any progress made by the child node will be reset, and it will start its execution from the beginning.
When a parent node restarts, it means the whole composite node begins its evaluation again from the beginning. This does not interrupt the child nodes.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I'm not mistaken, there can only be one running node - that is until parallel composites are implemented. But until then, I think the docs should reflect this fact and be clear about it as not to confuse the new users. Therefore, I suggest the last sentence be rewritten as follows: This does not interrupt the running child node.

## Ticking again a composite
## Interrupting child nodes

A sequence may interrupt any `RUNNING` child node in case a child returns a `FAILURE`. The `interrupt` method will be called on all child nodes of the currently evaluated child node.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A sequence may interrupt any RUNNING child node in case a child returns a FAILURE.

The interrupt can also happen in other cases, not just when a child returns a failure - for example, if a reactive sequence encounters a running child, that comes before the child that was running last frame, the old running child is interrupted. I'd say this part of the sentence can be left out: in case a child returns a FAILURE.

## Ticking again a composite
## Interrupting child nodes

A sequence may interrupt any `RUNNING` child node in case a child returns a `FAILURE`. The `interrupt` method will be called on all child nodes of the currently evaluated child node.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The interrupt method will be called on all child nodes of the currently evaluated child node.

The term child nodes typically denotes only the direct children, i.e. the first-order descendants. For clarity, I'd suggest using the term descendant nodes to denote all descending nodes and say ... will be called on all descendant nodes.

Also, instead of the currently evaluated child node, I'd say the interrupted child node just to make it clear which node we are referring to.


In other words, restarting a child node means that the parent node will give the child node a fresh start, while ticking it again means that the parent node will let the child node continue its execution from where it left off.
If a parent node ticks a child node again, it means that the parent node will immediately tick the child node again on the next frame, without waiting for the current frame to finish executing. This allows the child node to continue its execution from where it left off without resetting its progress.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

..., without waiting for the current frame to finish executing.

Is this correct? This sounds like the child node is ticked multiple times in the same frame. Isn't each node only ticked at most once on every frame?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Brain fog on my part. I will correct this.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I may add one more thing, I'd also maybe elaborate more to clarify that all that ticking again really means is that the parent composite node carries on with its execution from that given child node. Meaning, that it's not only that given child node that is ticked, it is potentially its sibling nodes following it, if the node completes and allows its siblings to be ticked too.

@bitbrain
Copy link
Owner Author

@rxlecky incorporated your feedback here: b07b02d

@bitbrain bitbrain merged commit 1acf549 into godot-4.x Nov 17, 2023
3 checks passed
@bitbrain bitbrain deleted the improve-restart-docs branch November 17, 2023 19:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Documentation for the behaviour of composite nodes is misleading
2 participants