Behavior Event Channels

Hi all,

does anyone have some experience with using Event Channels with the new Behaviour Tree asset. I seem to be getting terribly confused about how they work.

I understand a simple event channel. And I understand sending a shared event message to all the instances of the behaviour tree. You can use “Wait For” or “On Channel Message” to trigger a branch.

However, How can you send messages between different behaviour trees.

Let’s say I want Alice to send a message to Bob’s behaviour tree saying either “Hello” or “Come to my position” (which requires sending either a Transform or GameObject with the message). If Alice and Bobs BTs are different do you have to use a shared blackboard - but then it seems you can put event Channels on a shared blackboard? Is this right?

Anyway, any tutorials out there? I’m trying to speed up my understanding of event channels

Michael

Just to add some context.

Alice is on the left, highlighted and is running the AliceBT

and Bob is on the the right running the BobBT

They both have access to the SharedBlackBoardAliceAndBob

image

but when I run it I get an error

image

so it doesn’t seem to be registering the event somewhere. I need o do more digging but if anyone has more knowledge of what is going on I’d appreciate help.

Michael

Hi @Michael_Hutton,

I must admit I didn’t test the events on a blackboard asset myself and will need to look into it!

That said, if you had the event on the main blackboard itself in case we do have a bug, here is what you’d do:

  1. Create the event ScriptableObject in your project. (Right click in your Project, Create → Behavior → Event Channels → [Your Event Type] )
  2. Assign the same instance of the event to all agents you wish to share the same instance.

Essentially, if the Event is unassigned in the blackboard, the event will be local to the agent. If it is assigned, it’ll use the assigned one.

We need to check the case of it being in an assigned BlackboardAsset as it seems like it might not be creating the local variable if it is unassigned (which I am assuming to be your case).

I hope this helps!

Edit: I checked and @MorganHoarauUnity already worked on a fix for local events not being initialized in a blackboard asset!

Hmm. First, I might have been making a mess of things by not assigning the Self in the inspector Tree, sorry, my bad. I had previously been spawning a prefab and to test things I used a new project and missed this. :roll_eyes:

With creating the SO and assigning it in the SharedBlackboardAliceAndBob it works! Definitely progress but it’s a gotcha having to remember to assign everything. Simple but easily missed imho.

Thanks for replying.

When you said the ‘main blackboard’ I am assuming you meant the SharedBlackBoard? But this seems to work. It’s quite finickity to set up but I can see it’s power.

Oh, and where did the ‘Talk’ node go?

Michael

Also you can put an Event on a Shared Blackboard which you can use in a tree in Behavior 1.0.3 but not 1.0.1 it seems (I didn’t test 1.0.2).

It works!

So far…

Thanks for the help.

Hi @Michael_Hutton,

When I say main blackboard I mean the one that’s part of the graph, not the “SharedBlackboardAliceAndBob” you meant :slight_smile:

Adding the event manually should only be needed if it’s intended to be shared across agents, otherwise it’ll be making a local one by default. That said, there is a bug that’s preventing it from being initialized by default on Blackboard Assets. That’s already fixed in our development branch and will be out in a week or so.

It’s odd you needed to set Self manually, it should be automatically done for you :thinking:

The Talk node is in the sample :slight_smile:

I’m not sure I understand the question, sorry!

No drama. Sorry. It wasn’t really a question rather me putting down my thoughts.