Thank You, got it working.
Then he saw something in the distance, or rather someone. It was the figure of Heather Sweet. Heather was a sympathetic author with feathery feet and ugly elbows.
Yes, just send me an email/PM with your Behavior Designer invoice number and Iāll send you the link.
Opsive - again, great app, really appreciate it, the tutorials and your responsiveness on the forums.
Iām keen to learn more about how to intergrate the internal logic of, say, enemy action instantiated within Behvaior Designer, with features / triggers within an environment - that will be coded external to the package. What Iām interested in is the ability to, as the player, have an effect on the environment - say turning off/on a light, or making a noise, or killing an enemy (so either acting directly upon it, or via an intermediary game object that the enemy and itās ai are sensitive to) and have it respond. So say, enemy patrols, a door is opened remotely by the player, the enemy is aware, perhaps becomes suspicious as a result of the state chage, and begins a wander pattern beyond that threshold. So I want to create a state change in the world, outside of the behavior tree generated here, but have the tree recognise the change and respond accordingly. Fairly simple things, bool changes (light on/light off: door open/door closed).
Iām happy if the idea is that thatās best achieved via integrating with uScript or Playmaker, thatās cool. Or via script. Just keen for your thoughts. I donāt see a lot of coverage of this topic in other AI packages - and I think this has the best shot at making that work because of itās integration with playmaker and uscript.
Happy for your thoughts, at all. I guess the other way of saying it is, how to I provoke the ai behavior tree to produce a state change across the movement packages though my direct or indirect action on the environment outside of the behavior tree. Let me know if that makes any sense, or if youāre interested in throwing out any thoughts on it.
Cheers again
JCD
Itās great to hear that youāre enjoying it!
I can think of two approaches for your situation:
The most straight-forward way would be to place a selector at the top, followed by a sequence of tasks that first check a condition and then if that condition is true it will run the specified action. If an action does run then the selector task will return success and the other branch will not run. If you want it to be random for which condition is checked first then you can use a random selector instead of a selector. Hereās an example of that tree:

The second approach scales better but is a little bit more work to setup. Take a look at the Mini-Gauntlet project that I posted yesterday. Within that behavior tree is a new composite task called Task Trigger Selector. This task determines what child to run based off of the triggers/collision within the environment. For your specific situation, instead of having that task react based off of a trigger/collision you could have it react based off of a SharedInt that you set in a regular MonoBehaviour class. For example, I would modify TaskTriggerSelector so instead of nextTaskIndex being a private int it would be a public SharedInt. Then within the MonoBehaviour class you could do something like:
public void OnLightSwitch()
{
var nextTaskIndex = behaviorTree.GetVariable("NextTaskIndex") as SharedInt.
nextTaskIndex.Value = (int)TaskTriggerType.LightToggled;
}
The TaskTriggerType enum would look similar as what it does in the Mini-Gauntlet project. This approach scales really well.
I have a question about a possible use case, is Behavior Designer suitable to control in-game UI? I mean UI screen transitions, pop-up dialogs, HUD that persists over multiple scenes, etc. What is the best practice to control reusable UI components with Behavior Designer?
Iām having a question regarding the usage of the Movement Pack (which I bought yesterday to support the development :)). Iām setting up a simple BT consisting out of Selector with 2 Sequences. The idea is very basic: the agent goes on patrol and when he spots the player he has to seek it out (and eventually start to attack, in a later phase).
I have the impression the Object In Sight of the Can See Object is filled in with the Transform in sight, however how can I pass this to the Seeks Target Transform? Whatās the best approach to pass a variable from one Action to another Action. I tought I could use the Variables tab (Blackboard) but seems like you canāt assign a variable from the blackboard to an action not fill it with the Object in sight.
I never thought about using Behavior Designer in that way but if you wanted to give your UI an āAIā you could. The result could actually be pretty interesting. Each task is written very similar to the MonoBehaviour class - it has an awake, start, and update callback (along with a few others). You could get a reference to the UI that you are using and then do whatever you want to it, including screen transition, popup, etc. This is exactly what you would do with a any other object such as one derived from MonoBehaviour or a PlayMaker action. If you are thinking of using Unity GUI I should mention that tasks do not receive OnGUI callbacks so you would have to do something similar to what is done in the Mini-Gauntlet project where the task tells a MonoBehaviour object what to display. Does that help at all?
Thank you!
You should be able to pass the variable created within the Variables tab. I just tested this by creating a variable of type Transform:

And then assign that to the Object In Sight variable within the Can See Object task:
The seek task then takes a variable for the target to see to:
It can take a transform or a position. If the transform is null then it will use the position. In your case the transform will not be null so it should then seek towards the target that can see object saw.
Thanks for a cool suggestion, I was wondering what is the best representation for controlling UI flow, in some way these UI screens with a nested stack (you can open a popup from a popup, you can go back to the previous screen, and so on) can be represented by a hierarchical state machine, but it seems Playmaker FSM is not for that purpose. But with a behavior tree, it may be possible to reuse trees as modules/plugins and construct a robust UI system around that.
Thanks for the screenshots, they helped alot (didnāt know what why those point images are used, now I do).
However a new issue popped up: when the BT switches from the Patrol state to the Seek state the nav agent is halted and throws the error āSetDestination can only be called on an active agent that has been placed on a NavMeshā over and over again. Although itās the same agent so I donāt understand what causes this behavior. Maybe its my behavior tree?
Can you please give me some advice on how to proceed or how to set up my BT to interupt de patrol action once the player is spotted, as I guess the source of the problem is my tree setup (and there is nothing wrong with the Movement actions).
@RyuK -
To be honest, after seeing what you want to do, I think the easiest way would be to not use a FSM/behavior tree at all and just script it. The pushing/polling of the popups would be handled by a stack, and you would easily be able to handle the click events. That said, if you really wanted to use a behavior tree I think you could. You would still need a task that uses the stack object type to keep track of your level in the hierarchy, and then from there you would have two options for handing click events similar to the situation that I described to jcdenton.
When Behavior Designer runs, it executes all of the tasks in one branch before it starts on another branch. In your example, it is executing Can See Object, Perform Interruption, then Seek. After that it interrupts the Patrol task. When each movement task ends it disables the navigation mesh. This is the problem that youāre running into. The seek task starts up, starts moving, then immediately after that the patrol task ends and disables the navigation mesh. There are two ways to solve this. You can either comment out the line that disables the navigation mesh of the tasks (within OnEnd), or you could introduce a very slight delay after the perform interruption task. This would ensure that patrol ends before seek starts. If you set a delay as small as 0.001 it will work.
Edit: Another option would be to uncheck the instant property on the perform interruption task. This will delay the seek task from starting until the next tick and the patrol task would have ended by then. If you do this then you donāt need the wait task:

Thanks for the info, however I had to implement a short delay (your first suggestion) because the instant uncheck trick doesnāt seem to work. But the issue is resolved, thanks.
hmm, instant should basically do the same thing. If you donāt want that extra wait task in there I donāt mind taking a look at the tree to see why it isnāt working.
I tried to replicate it in a new project but then the instant is indeed working, unfortunatly the production project is more then 15 GB ![]()
Another question Iām facing: Is it possible to use a generic public list in an action to set within the behavior editor?
I want to create one mecanim action to rule them all, meaning 1 action where I can set the values of the booleans, floats, etc that drives my mecanim states.
I created a class called MecanimParameter but when I try to use it the BT editor just ignores it:
public List<MecanimParameter> Parameters;
Nevermind, it helps if I set my MecanimParameter to [Serializable].
Yeah, the base class needs to be marked as Serializable. On the instant problem, instead of sending me the project can you save the behavior tree that is having problems to a .asset file and send me that? I can then take a look at the serialization and hopefully recreate what you are seeing. The .asset file should be much, much smaller than your entire project ![]()
I mailed the requested file(s) to your support mailbox.
For the past few days I have been working on a new asset integration and I am happy to announce that version 1.2.2 will feature Dialogue System for Unity integration! The following tasks will be included:
Bark
RunLua
SetQuestEntryState
SetQuestState
StartConversation
StartSequence
StopConversation
StopSequence
IsLuaTrue
QuestEntryState
QuestState
Hereās an example of a behavior tree:
When a behavior tree starts a conversation or sequence it will wait until that conversation or sequence has completed before it moves onto the next task, similar to the PlayMaker/uScript tasks. After playing with it for awhile I think that the two assets really go hand-in-hand with each other.
How cool is that? Iām Looking forward to everything that comes my way.
Hi Opsive,
I would like to ask three questions :
-As I understand from your previous posts, it seems it is not possible to use a class as shared object such as a script inside a game object. Am I correct and if there is another way to pass a class to another branches, can you give one line example?
-You have sharedobject but I couldnāt see any example to use it anywhere. As I understand, it shares component such as NavMeshAgent. Can you give me a one line example to solve it?
-I am using a tree that I posted here. On this tree, I am using a sequence that has to be keep going till the enemy is sighted and it will perform interruption on the sequence. All your examples you have provided, the interruption is applied on an Action but I want to apply it to a sequence like here. But it is not working. Can you give me an idea where am I doing wrong and how to interrupt secuences(stop all their children) properly?
Thanks







