Comments (3)
Yes you're right. The idea behind the ON_CHANGE is not really clear from it's name.
The idea was to have no condition on the value itself (that's why it's always true), but rather have the possibility to re-evaluate the "stops condition" whenever the value in the blackboard changed. I think this was useful to me to be sure a specific subranch is always re-executed on a value change, regardless of it's contents. For a loop by that would also execute like you pointed out.
The thing you want to achieve would require the decorator to remember the last known value of the blackboard and then compare this on execution. I can add such a decorator this evening (or at least post you some code here) if you like.
I will defiantly rename the Operator.ON_CHANGE operator to something like Operator.ALWAYS_TRUE, as it's indeed confusing right now.
from npbehave.
You could create your own new node type that does track for changes on a blackboard key. Something like that should work for you:
using NPBehave;
public class BlackboardValueChanged : Decorator
{
private object lastValue;
private string blackboardKey;
public BlackboardValueChanged(string blackboardKey, Node decoratee) : base("BlackboardValueChanged", decoratee)
{
this.lastValue = null;
this.blackboardKey = blackboardKey;
}
protected override void DoStart()
{
object newValue = RootNode.Blackboard.Get(blackboardKey);
if (lastValue != newValue)
{
lastValue = newValue;
Decoratee.Start();
}
else
{
Stopped(false);
}
}
override protected void DoStop()
{
Decoratee.Stop();
}
protected override void DoChildStopped(Node child, bool result)
{
Stopped(result);
}
}
I didn't test it, but I think you should be able to adjust it for your needs.
from npbehave.
Aha Ok,
I got it now, only naming thing,,
No worries,
And thanks for the "BlackboardValueChanged" code.
from npbehave.
Related Issues (20)
- how to use BlackboardQuery ? I get confused. I need example, please. HOT 5
- GC/Performance problems HOT 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
- Purpose of bool param in multiframe Action HOT 9
- 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
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.