Question on Flowgraph Nodes for ComponentEntity EventHandlers

Hey guys,

At present I’m trying to prototype a silly game concept using a combination of flowgraph and lua scripts. I’d eventually like to get to programming my games in C++, but it’s not been super clear to me how to set my dev environment up to do this – there’s not really a connected bridge between the super high-level flowgraph stuff in the getting started tutorials, the medium-level stuff surrounding lua, and the low-level C++ stuff that a relatively new person to professional game development / 3D game engines can intrepidly follow to obtain mastery over the engine – though that’s probably feedback for a different question.

Anyways, for now all I’m trying to do is send the “world vector” from the Input:MouseCoords flowgraph entity into a bus so I can do some things with it* inside of a component entity lua script. However, at the flowgraph level, I have two choices for what type of bus to use: GameplayEventSender/Handler:AZVector3 and EventActionSender/Handler:AZVector3. What are the differences/tradeoffs between these two buses and when would I want to utilize each? In addition, what class of handler would I want to use in Lua to receive the vector (not sure if there’s a common place where they are located in source).

From anecdotal testing they both appear to successfully deliver the “world vector” to their appropriate handler elsewhere in the flowgraph, but their entity descriptions (the one you get when you hover over the entity) are frustratingly blank, and the online documentation on component entities and event buses isn’t too helpful here either. My next step would be to find the C++ implementations of each of these flowgraph entities and hope that there are helpful comments or reverse engineer it, but I don’t know of an easy way to search Lumberyard’s C++ / lua source for arbitrary class names and such, and manually searching for it is optimistic at best.

Thanks in advance for the help,


  • With regards to the Input:MouseCoords flowgraph entity and its “world vector”, I’ve found through testing that the “world vector” is really more of a “camera space vector” – the vector you receive appears to be constructed from i, j, and k, vectors that correspond to the camera entity’s rightDir, upDir, and -fwdDir vectors respectively. As such, before I can use the “world vector” as a “vector that points in a meaningful direction in world space” I have to transform it using a change of space matrix. That’s not that terrible in the scheme of things, and I do find the flowgraph entity to be quite useful, but I initially felt rather misled by the entity description and I only managed to figure things out by noticing that the x and y components of the “world” vector went from (+,+) to (-,+) to (-,-) to (+,-) as you moved your mouse counter-clockwise from the first quadrant of the screen to fourth quadrant of the screen, regardless of camera orientation. Just extra feedback.

Hi @Hylebos,

The EventActionHandler and EventActionSender are alias for the GameplayEvent Handler and GameplayEventSender.

Here’s where they are defined in GameplayEventHandlerNode.cpp

using GameplayEventHandlerFloat = GameplayEventHandlerNode<float>;
using GameplayEventHandlerAZVector3 = GameplayEventHandlerNode<AZ::Vector3>;
using GameplayEventHandlerEntityId = GameplayEventHandlerNode<FlowEntityId>;
using GameplayEventSenderFloat = GameplayEventSenderNode<float>;
using GameplayEventSenderAZVector3 = GameplayEventSenderNode<AZ::Vector3>;
using GameplayEventSenderEntityId = GameplayEventSenderNode<FlowEntityId>;
REGISTER_FLOW_NODE_WITH_ALIASES("ComponentEntity:GameplayEventHandler:Float", GameplayEventHandlerFloat, "ComponentEntity:EventActionHandler:Float");
REGISTER_FLOW_NODE_WITH_ALIASES("ComponentEntity:GameplayEventSender:Float", GameplayEventSenderFloat, "ComponentEntity:EventActionSender:Float");
REGISTER_FLOW_NODE_WITH_ALIASES("ComponentEntity:GameplayEventHandler:EntityId", GameplayEventHandlerEntityId, "ComponentEntity:EventActionHandler:EntityId");
REGISTER_FLOW_NODE_WITH_ALIASES("ComponentEntity:GameplayEventSender:EntityId", GameplayEventSenderEntityId, "ComponentEntity:EventActionSender:EntityId");
REGISTER_FLOW_NODE_WITH_ALIASES("ComponentEntity:GameplayEventHandler:AZVector3", GameplayEventHandlerAZVector3, "ComponentEntity:EventActionHandler:AZVector3");
REGISTER_FLOW_NODE_WITH_ALIASES("ComponentEntity:GameplayEventSender:AZVector3", GameplayEventSenderAZVector3, "ComponentEntity:EventActionSender:AZVector3")

You can use these buses to send an event from Flowgraph to Lua like the MouseCoord output like so:

  1. Create a component entity

  2. Right click on that entity in the viewport and select Flowgraph > Add from the context menu

  3. Create flowgraph nodes and hook em up like this:

    To assign the component entity to the Entity:EntityId node, select the component entity in the viewport and then right-click the Entity:EntityId node and select “Assign selected entity”.

  4. Add a Lua component to the entity

  5. Create a Lua script called example_handler.lua that contains the following and assign it to the Script property on the Lua Script component.

	example_handler = {
Properties = {
function example_handler:OnActivate()
local eventName = "ExampleEvent" -- Could expose this as a property
-- In this example we are only handling one event
-- For multiple event handlers you probably want to use a member
	-- like self.EventHandlers.handler1, self.EventHandlers.handler2 etc. self.eventHandler = Vector3GameplayNotificationBusHandler(self, GameplayNotificationId(self.entityId, eventName))
function example_handler:OnGameplayEventAction(value)
Debug.Log("Value received: " .. tostring(value))
function example_handler:OnDeactivate()

To test, just enter game mode (CTRL+G) and look for the output in the console. Let me know if you have any questions!

Thanks @petrocket, your answer helped tremendously, especially with all the extra screenshots and code examples! For anyone else who’s having trouble with Entity Buses in Lua, I also found the block comment at the top of Lumberyard\\dev\Code\Framework\AzCore\AzCore\EBus\ScriptBinder.h to be super useful for figuring out how to send vectors back to the flowgraph.