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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repeater entering INVALID state on child running #2

Open
crashtheuniverse opened this issue Feb 17, 2020 · 1 comment
Open

Repeater entering INVALID state on child running #2

crashtheuniverse opened this issue Feb 17, 2020 · 1 comment

Comments

@crashtheuniverse
Copy link

return BH_INVALID;

Is this intended? What I'm seeing is that following this logic, the Repeater as soon as one of the children is in running phase, will return INVALID as it's status.

This will in turn go back to the base class Behavior that will see that the status != RUNNING, and terminate the behavior.
Since the implementation of a basic Repeater has an empty ::onTerminate seems like nothing is effected if that's a top level node. However the side effects show as soon as it is used to repeat a set of actions further down the tree.

Shouldn't it return a RUNNING state instead?

Maybe I'm misinterpreting the intended behavior, as we want the action to be repeated quickly in the same frame / context?
One of the examples from the aigamedev paper says "shootPlayer" 3 times. If that is a sequence in itself, (like imagine an old sniper rifle: reload, aim, shoot, reload, aim, shoot..) each phase may have a short running period.
If that's not how it is intended ok, but otherwise I see that as a potential problem.

Thank you

@ljluestc
Copy link

ljluestc commented Jan 6, 2024

// Inside Repeater::tick() method
for (int i = 0; i < repeatCount; ++i) {
    // Execute the child node
    Status childStatus = child->tick();
    
    if (childStatus == BH_RUNNING) {
        // If the child is still running, return BH_RUNNING
        return BH_RUNNING;
    } else if (childStatus == BH_FAILURE) {
        // Handle failure (e.g., repeat or exit)
        return BH_FAILURE;
    }
    // Handle success (e.g., repeat or exit)
}
// All repetitions completed, return BH_SUCCESS or BH_FAILURE based on the logic.

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

No branches or pull requests

2 participants