Comments (9)
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.
I see. Can Result.BLOCKED be returned? Tho thb, not fully sure what the difference between FAILED and BLOCKED is.
from npbehave.
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.
Understood, what sould be returned then when task is "cancelled"? Is the result even considered?
from npbehave.
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.
I meant that the bool param passed is a request to cancell
from npbehave.
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 EDIT: I read up the code and it's also the case for IMMEDIATE_RESTART rules: see next comment belowIMMEDIATE_RESTART
or LOWER_PRIORITY_IMMEDIATE_RESTART
the return code shouldn't matter.
For now I would suggest you to always return Fail
in case you got cancelled.
from npbehave.
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:
- in case the aborted branch is nested inside a
Selector
node and stops with aFAILED
:
- 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)
- in case the aborted branch is nested inside a
Selector
node and stops with aSUCCESS
:
- without
IMMEDIATE_RESTART
: the selector would succeed (traversal continues as usual) - with
IMMEDIATE_RESTART
: the selector would succeed (traversal continues as usual)
- in case the aborted branch is nested inside a
Sequence
node and stops with aFAILED
:
- without
IMMEDIATE_RESTART
: the sequence would fail (traversal continues as usual) - with
IMMEDIATE_RESTART
: the sequence would fail (traversal continues as usual)
- in case the aborted branch is nested inside a
Sequence
node and stops with aSUCCESS
:
- 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.
I've documented the parameter in the README https://github.com/meniku/NPBehave#action
from npbehave.
Related Issues (20)
- Randomized Nodes HOT 16
- Still maintained? HOT 3
- BlackboardCondition seems can't stop lower priority repeater node when using a child blackboard HOT 2
- NPBehave TimeScale starts with 0
- [Question] Clock timer with repetitions HOT 3
- I want to do something for the Project.Among them, visual editing behavior, Chinese documents HOT 13
- Assertion in Wait action HOT 1
- NPBehave 2.0 Changes - Wishlist HOT 15
- Null check on Condition node works but not on BlackboardCondition node HOT 2
- RandomSequence Stop wrong children HOT 1
- Pausing the behavior tree HOT 8
- Naming nodes HOT 7
- Creation Utility class HOT 3
- NavMoveTo always fails when stopOnTolerance==true HOT 3
- simpleAI example problem HOT 3
- A question about the source code of Clock.cs and Blackborad.cs HOT 2
- It is not possible to handle player input because the tree cannot wait for some action while execute other in parallel HOT 1
- Question about order of timers HOT 1
- 2.0 Does the behavior tree fail to remove the old timer when restarting?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from npbehave.