Giter Club home page Giter Club logo

Comments (9)

meniku avatar meniku commented on July 23, 2024

this parameter is true in case another node requests your action to be stopped. In this case you will need to abort your action and are not allowed to return Result.PROGRESS.

This can happen for example if you have another decorator on another branch that watched for a blackboard condition that now became true.

from npbehave.

slimshader avatar slimshader commented on July 23, 2024

I see. Can Result.BLOCKED be returned? Tho thb, not fully sure what the difference between FAILED and BLOCKED is.

from npbehave.

meniku avatar meniku commented on July 23, 2024

ah right, BLOCKED might be not very obvious, it's meant in case you need to wait for some kind of initialisation before you want your action to be started. It doesn't actually abort the task like returning FAILED would do, but try to trigger your action again next frame without re-evaluating the parent nodes or even the entire tree ( as returning FAILED could potentially do ).

Anyway that's more for kinda specific uses, so the recommended way would be to create your own Tasks classes anyway .

from npbehave.

slimshader avatar slimshader commented on July 23, 2024

Understood, what sould be returned then when task is "cancelled"? Is the result even considered?

from npbehave.

meniku avatar meniku commented on July 23, 2024

In NPBehave terms, you cannot "cancel" a task from within the task. A task can either: Succeed, Fail or stay in Progress.

Cancelling always happens either by some other higher priority node requesting stopping of your node, the entire BT being stopped or if you hit the Stop Button in the Debugger window.

So in case something inside your task logic wants the task to stop running, what you want to do from within the task is Succeed or Fail. For example if you have an "Attack" Task, but the player blocked it, you could "Fail" your Task to allow a parent selector node to fallback to a different strategy. If you fail or succeed depends really on the way how you structure your BT.

from npbehave.

slimshader avatar slimshader commented on July 23, 2024

I meant that the bool param passed is a request to cancell

from npbehave.

meniku avatar meniku commented on July 23, 2024

sorry, of course!
So in that case you either return Succeed or Fail, again depends on the structure of your BT. In case you got aborted with IMMEDIATE_RESTART or LOWER_PRIORITY_IMMEDIATE_RESTART the return code shouldn't matter. EDIT: I read up the code and it's also the case for IMMEDIATE_RESTART rules: see next comment below

For now I would suggest you to always return Fail in case you got cancelled.

from npbehave.

meniku avatar meniku commented on July 23, 2024

OK sorry to make this detailed explanation here, but it has been a while since I implemented it and a a general answer on what to return (SUCCESS or FAILED) is not really possible, but I want to give you the best explanation possible.

The following is however only relevant if you actually use Stops rules. If not, then just ignore the whole topic and just always return FAILED - the cancel boolean should never be true in that case anyway

I've checked the unit tests and to clarify, regardless of the Stops rule you use, the return code of a branch will result in the parent composite to continue it's execution based on the composite's rules.

So to give some examples:

  1. in case the aborted branch is nested inside a Selector node and stops with a FAILED:
  • without IMMEDIATE_RESTART: would just start the next child of the Selector
  • with IMMEDIATE_RESTART: would start the node that cancelled your action
  • (that's why I recommend returning FAILED if in doubt, because from my experience this is most likely what you want)
  1. in case the aborted branch is nested inside a Selector node and stops with a SUCCESS:
  • without IMMEDIATE_RESTART: the selector would succeed (traversal continues as usual)
  • with IMMEDIATE_RESTART: the selector would succeed (traversal continues as usual)
  1. in case the aborted branch is nested inside a Sequence node and stops with a FAILED:
  • without IMMEDIATE_RESTART: the sequence would fail (traversal continues as usual)
  • with IMMEDIATE_RESTART: the sequence would fail (traversal continues as usual)
  1. in case the aborted branch is nested inside a Sequence node and stops with a SUCCESS:
  • without IMMEDIATE_RESTART: would just start the next child of the Sequence
  • with IMMEDIATE_RESTART: would start the node that cancelled your action

So as I said, it really depends on what you want, however to get closest to UE4s behaviour I would recommend returning FAILED and using the IMMEDIATE_RESTART versions of the stops rules.

It's possible that I will simplify aborting rules in a future version of NPBehave, because actually the non-IMMEDIATE_RESTART are imo not really that useful and in any case, aborting should always just continue execution at the node that aborted it.

from npbehave.

meniku avatar meniku commented on July 23, 2024

I've documented the parameter in the README https://github.com/meniku/NPBehave#action

from npbehave.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.