luis-l / bonsaibehaviourtree Goto Github PK
View Code? Open in Web Editor NEWAn advanced behaviour tree solution for the Unity game engine
License: MIT License
An advanced behaviour tree solution for the Unity game engine
License: MIT License
https://gyazo.com/7f2363ea32ec669d66baea3aa477be18
in this example i want the combat branch to run if the value has player is true.
the tree start with value true so it run the left side of the branch.
i change to false then the selector will run the idle task on the right
but when i change it back to true then the left side "combat branch" is not evaluated again.
how can i fix this? other behavior tree i used got this behavior working
Components inherited from BonsaiTreeComponent are not displayed in the BonsaiTreeWindow.
'Delete' key for deletion.
'Ctrl + D' for duplicating nodes.
WTR:
ArgumentNullException: Value cannot be null. Parameter name: key System.Collections.Generic.Dictionary
2[TKey,TValue].FindEntry (TKey key) (at <695d1cc93cca45069c528c15c9fdd749>:0)
System.Collections.Generic.Dictionary2[TKey,TValue].get_Item (TKey key) (at <695d1cc93cca45069c528c15c9fdd749>:0) Bonsai.Designer.BonsaiCanvas.ReconstructEditorConnections (System.Collections.Generic.Dictionary
2[TKey,TValue] nodeMap) (at Assets/3rdParty/BonsaiBehaviourTree/Editor/BonsaiCanvas.cs:214)
Bonsai.Designer.BonsaiCanvas..ctor (Bonsai.Core.BehaviourTree tree) (at Assets/3rdParty/BonsaiBehaviourTree/Editor/BonsaiCanvas.cs:28)
Bonsai.Designer.BonsaiEditor.SetBehaviourTree (Bonsai.Core.BehaviourTree tree) (at Assets/3rdParty/BonsaiBehaviourTree/Editor/BonsaiEditor.cs:360)
Bonsai.Designer.BonsaiWindow.BuildCanvas () (at Assets/3rdParty/BonsaiBehaviourTree/Editor/BonsaiWindow.cs:218)
Bonsai.Designer.BonsaiWindow.OnGUI () (at Assets/3rdParty/BonsaiBehaviourTree/Editor/BonsaiWindow.cs:92)
UnityEditor.HostView.InvokeOnGUI (UnityEngine.Rect onGUIPosition, UnityEngine.Rect viewRect) (at <63ccfe108ffa44728b417cb47fb2f841>:0)
UnityEditor.DockArea.DrawView (UnityEngine.Rect viewRect, UnityEngine.Rect dockAreaRect) (at <63ccfe108ffa44728b417cb47fb2f841>:0)
UnityEditor.DockArea.OldOnGUI () (at <63ccfe108ffa44728b417cb47fb2f841>:0)
UnityEngine.UIElements.IMGUIContainer.DoOnGUI (UnityEngine.Event evt, UnityEngine.Matrix4x4 parentTransform, UnityEngine.Rect clippingRect, System.Boolean isComputingLayout, UnityEngine.Rect layoutSize, System.Action onGUIHandler, System.Boolean canAffectFocus) (at <3b9216b5eb2547d2a9ee9f63fc12b7c2>:0)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)`
Add action to hide subtrees
The editor should have its own undo structure, so it does not interfere with Unity's undo.
Ideally, control+u
would be the default undo action trigger. Unsure if it is possible to prevent Unity from also using control+u
after the BonsaiEditor uses it.
I think a persistent data structure could be used as the underlying mechanism for undo. This will store state for every tree change. Undo/Redo will simply be moving up or down a list which stores copies of the persistent data structure.
If you add a description to ConditionalAbort by inheriting from Description, there is not enough spacing between the description of the base class and the description of the inheritor.
The nicify feature needs to be fixed so it works with variable sized nodes
Here is an example condition:
namespace Bonsai.Standard { [BonsaiNode("Conditional/", "Condition")] public class HasEnemy : ConditionalAbort { public override bool Condition() { var character = Blackboard.Get<BaseCharacter>("baseCharacter"); return character.Target != null; } } }
do you have an example how to initialize that blackboard so it is correctly instanced with its owner so each unique character have their own instance of blackboard.
also if i assign the same scriptable BT to 2 different character, will they share the same scriptable BT or make instances?
It looks very promising, and I'm considering using it for my project. Is it still being developed?
Comparator feature.
A comparator takes values from two child nodes and compares them.
Usage examples:
Calculating the distance between two objects.
Any arithmetic operations.
This also includes Getter nodes. They fetch objects and classes from the external world.
Usage examples:
Fetching the player object to later check the distance.
Set and Get variable to/from Blackboard
Since the blackboard doesn't allow linking references from outside, and since the entire tree gets duplicated, resulting in a 'Type mismatch' + blackboard cannot be viewed during execution, Getter nodes solve this problem.
At least Conditional Abort and Timer are bad which are essential in behaviour tree development.
When creating a new Behaviour Tree from the editor, it creates and saves the new asset in a specified temporary directory that cannot be changed.
The directory is also useless. Temporary(unsaved) trees are immediately removed when entering play mode or closing the window.
When creating a new tree for the first time, it should not be saved any where. Saving only occurs when the user does a Save/SaveAs action.
After restarting a scene where I had built two trees with custom nodes, one of them doesn't work anymore. Upon Entering Play Mode I get this error :
ArgumentException: The Object you want to instantiate is null.
UnityEngine.Object.CheckNullArgument (System.Object arg, System.String message) (at <29ad182faa3f478c9310d6a2e7143c15>:0)
UnityEngine.Object.Instantiate[T] (T original) (at <29ad182faa3f478c9310d6a2e7143c15>:0)
Bonsai.Core.BehaviourTree+<>c.b__39_0 (Bonsai.Core.BehaviourNode n) (at Assets/BonsaiBehaviourTree/Core/BehaviourTree.cs:340)
System.Linq.Enumerable+SelectArrayIterator2[TSource,TResult].ToArray () (at <351e49e2a5bf4fd6beabb458ce2255f3>:0) System.Linq.Enumerable.ToArray[TSource] (System.Collections.Generic.IEnumerable
1[T] source) (at <351e49e2a5bf4fd6beabb458ce2255f3>:0)
Bonsai.Core.BehaviourTree.SetNodes (System.Collections.Generic.IEnumerable`1[T] nodes) (at Assets/BonsaiBehaviourTree/Core/BehaviourTree.cs:118)
Bonsai.Core.BehaviourTree.Clone (Bonsai.Core.BehaviourTree sourceTree) (at Assets/BonsaiBehaviourTree/Core/BehaviourTree.cs:340)
Bonsai.Core.BonsaiTreeComponent.Awake () (at Assets/BonsaiBehaviourTree/Core/BonsaiTreeComponent.cs:22)
UnityEditor.HostView.Invoke (System.String methodName, System.Object obj) (at <7d90b28560b644ce87b8263efcc36eed>:0)
UnityEditor.HostView.Invoke (System.String methodName) (at <7d90b28560b644ce87b8263efcc36eed>:0)
UnityEditor.HostView.InvokeOnGUI (UnityEngine.Rect onGUIPosition, UnityEngine.Rect viewRect) (at <7d90b28560b644ce87b8263efcc36eed>:0)
UnityEditor.DockArea.DrawView (UnityEngine.Rect viewRect, UnityEngine.Rect dockAreaRect) (at <7d90b28560b644ce87b8263efcc36eed>:0)
UnityEditor.DockArea.OldOnGUI () (at <7d90b28560b644ce87b8263efcc36eed>:0)
UnityEngine.UIElements.IMGUIContainer.DoOnGUI (UnityEngine.Event evt, UnityEngine.Matrix4x4 parentTransform, UnityEngine.Rect clippingRect, System.Boolean isComputingLayout, UnityEngine.Rect layoutSize, System.Action onGUIHandler, System.Boolean canAffectFocus) (at <06214b245dbb4d10a9cefd10639bb04e>:0)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
It's quite annoying because there was quite a lot of work there, and now I can't even open the graph. I don't know if this because of some nodes I made, but it worked perfectly when I closed Unity a few hours ago...
Editor Assembly wil be applied on building app.
The only multi-selection available in editor is the area selection.
Multi-selection should also work by clicking nodes. e.g. control+click
to add/remove nodes from selection group.
This could also be extended to multi-select nodes in a "range" (e.g. shift+click). For example, select all nodes under a branch with the same level-order, or all nodes between parent and click child (depth-first path)
Though this could be handled by area selection for most use cases.
Hi, would it be possible to add Unity's package manager support for easy updating straight from the git repository? Thanks for a great asset btw!
The Change Type action is not implemented.
Change Type changes the underlying BehaviourNode
represented by the BonsaiNode
.
Conversions can only be done for behaviours of the same base type:
Conversion need to preserve all input and output connections.
hi, i had to delete the "Tests" directory because of compilation errors (also if i added the package NUnit)
it would be nice if it was in a test branch or something alike.. so that we can add this framework as a git submodule without major issues
hello, is there any unity sample to show the features that display in the screenshot / videos, it will help us how to use quickly, thanks.
Hi,
first of all, good work so far. I could easily get started with latest unity and create a simple tree.
I could also create a custom task using your example from the readme. One problem I have is how a task can be written for a specific game object. Since tasks are scriptable objects this doesn't seem to be so simple. (I could probably find the object and perform some action (e.g. using the navigation agent to move to a new target), however this would be very slow.
I'm sure that I must be doing something wrong but I feel that either adding some more advanced examples or writing a documentation would help. (I know it's still in progress and these things might be already planned, but I'm just impatient).
regards
It should inherit so Inspector changes are reflected in Bonsai editor
the asset in result will be corrupted
When duplicating multiple nodes at a time, the connections between those nodes are broken in the clone.
The connections should be preserved.
the designer is always in edit mode and play mode doesn't show at all. I'm using Unity 2022.
is there something that I have missed?
NullReferenceException: Object reference not set to an instance of an object Bonsai.Designer.BonsaiCanvas.CreateNode (Bonsai.Core.BehaviourNode behaviour) (at Assets/3rdParty/BonsaiBehaviourTree/Editor/BonsaiCanvas.cs:49) Bonsai.Designer.BonsaiCanvas.ReconstructEditorNode (Bonsai.Core.BehaviourNode behaviour) (at Assets/3rdParty/BonsaiBehaviourTree/Editor/BonsaiCanvas.cs:198) Bonsai.Designer.BonsaiCanvas.ReconstructEditorNodes (System.Collections.Generic.IEnumerable
1[T] behaviours) (at Assets/3rdParty/BonsaiBehaviourTree/Editor/BonsaiCanvas.cs:189)
Bonsai.Designer.BonsaiCanvas..ctor (Bonsai.Core.BehaviourTree tree) (at Assets/3rdParty/BonsaiBehaviourTree/Editor/BonsaiCanvas.cs:27)
Bonsai.Designer.BonsaiEditor.SetBehaviourTree (Bonsai.Core.BehaviourTree tree) (at Assets/3rdParty/BonsaiBehaviourTree/Editor/BonsaiEditor.cs:360)
Bonsai.Designer.BonsaiWindow.BuildCanvas () (at Assets/3rdParty/BonsaiBehaviourTree/Editor/BonsaiWindow.cs:218)
Bonsai.Designer.BonsaiWindow.OnEnable () (at Assets/3rdParty/BonsaiBehaviourTree/Editor/BonsaiWindow.cs:61)`
The BehaviourTree and BehaviourNode classes store Tree Meta Data.
The meta data is defined inside UNITY_EDITOR blocks and stores information such as Node Position, Pan, Zoom, etc. This meta data is only relevant to the BonsaiDesigner.
This was initially done so data was centralized in one place and serialized along with the ScriptableObject.
The data should be moved outside the core classes.
An approach can be storing all this data in a separate ScriptableObject (TreeMetaData class). This object would be added under the BehaviourTree asset object so all data is centralized. In play mode, the tree instance running will not use this data at all.
Even though there is text and icons to identify nodes, colorblind options could still be useful to quickly differentiate node types and ports.
i cant save a behaviour tree, it says saved but it doesn't save
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.