Event Channels in Muse Behavior

Is there an example of using Event Channels or some basic documentation? I want to trigger a state change in the Graph from outside the Graph.

Hi @thubbardnd!

To get started with Event Channels, you can create a new Event Channel through the “+” menu on the Blackboard (Events > Add new event channel type). This will open a event channel wizard window, where you can define your event name and message, and any variable types you want to send with the message:

To add an event channel variable to your Blackboard, you can now go back to the same “+” menu and add a new variable from your newly created channel. We’re planning to make this a bit easier so that a channel variable would be automatically created on the Blackboard after creating a channel, but for now you’ll have to go and create one from the menu yourself. After doing this, you should have a ready to use event channel variable on your Blackboard.

To finally send an event message on the channel you have just created, you can now add a Send Event Message action node to your graph. To receive a message, you should add a Wait for Event Message action, and assign both of them the same event channel variable to use. If you send any variables with your message, you can assign the received variables in the Wait node to be used. In addition, you could also start a graph from a “Start on Event” root node, which also waits and listens to an event. Here is a quick and really simple (although maybe not very realistic) example of how to set up the Send and Wait nodes:

Unfortunately at this time we still don’t support sending events between different graph assets as the Event Channel variables are specific to the Blackboards, so for now all event calls should happen inside the graph that is being edited. We’re planning to add this feature in a future update. :slight_smile:

Let me know if you need anything more to get started, or if you have any additional feedback on the tool!

1 Like

Thank you so much, this is super helpful! I appreciate all the details. I now know how to use those and will test them for sure.

Related question: I had thought that Event Channels would have been a way for code outside the Behavior Tree to trigger events within the tree. How should that be done? If, for example, I want to wait until a player clicks a button on a canvas and then change the state.

Hey @thubbardnd ,

Look at the event channel .cs script generate, it has a pre-generated SendEventMessage method. When you created a Scriptable Object instance of the event channel and assign it to an agent, you can also use the same Scriptable Object instance to call SendEventMessage for all agents who share that message :slight_smile:

I have been using this code for a bit to call an event inside my graph a projectile hits and enemy and it works just as I hoped with only calling the event for the agent it’s on.:

BlackboardVariable test;
other.GetComponent().Blackboard.TryGetVariable(“GotShot”, out test);
((ShotByPlayer)test.ObjectValue).SendEventMessage();

I’m wondering how I could apply this to call a different event to hit all agents that use the same graph or if I would just have to loop through all of the agents for a global event

Hi @barretkeyes ,

Have you created a ScriptableObject instance (asset) of the event channel? If so, assign the same asset to all the agents you want to share it and to your caller and use the instance to call the event message. I hope that makes sense?

Oh, my apologies. When reading your ordinal answer I was still thinking of an instance of the event inside the graph and not creating an instance of the event just as a scriptable object outside of that. Thank you!

You’re welcome! Please let us know if you’re still having any issues :slight_smile: