Different event handling behavior between PIE and Standalone with actor inheritance and actor components. What's the right way?

jdh25501
Sun, 31 Dec 2023 20:20:23 +0000
Programming & Scripting

TL;DR - what’s the best way of creating common event handling logic in a parent class and combining it with specific event handling from a child class? I’ve observed different behavior based on event type and on PIE vs Standalone. So, I’m wondering if there’s a best practice of how to do this? I couldn’t find this topic addressed in the UE docs…

Long version:

I have created a hierarchy of three player controllers. The base is the UE Player Controller, then I have a controller that deals with send/receive of messaging over pixel streaming and at the bottom I have the controller that is specific to my application. The idea being that I can re-use the controller that does the pixel streaming stuff between different projects.

The functionality for the pixel streaming message handling is mostly done in an actor component instantiated in the pixel streaming controller.

The functionality for the specific application is handled in an actor component.

I’ve done it this way as a way of separating the code into different logical modules.

Here’s a diagram:

PIE with mouse handler:
If I have a mouse button click handler in all four event graphs (A,B,C,D) and run in PIE only one fires. With all four in place just D fires. Remove D and then B fires. Remove that and then just C. Remove C and then A fires. So, in order of priority in PIE it’s D->B->C->A.

Standalone with mouse handler:
Same scenario - button click handler in all four event graphs. In this case NOTHING fires. Remove D and then B fires and we get into the same hierarchy: B->C->A.

PIE with Event Tick handler:
If I have an event tick handler in B and D then both handlers fire: B,D,B,D etc.

Standalone with Event Tick handler:
Same scenario - I have an event tick handler in B and D then just B fires: B,B,B,B etc.

Note: in both Standalone cases it’s like the app specific component (D in the diagram) doesn’t exist…

All of this is implemented in Blueprints with just a Print String tied to the event handler.

I’m CAF… (confused as f***).

1. I realize it’s an arbitrary decision of where I’ve put my stuff. I think I’m going to change things such that the player controllers deal with native events and fire custom events to be handled by the actor components. So, I think I can get it working.

2. However, I’d like to understand if there’s some “official” hierarchy of event handling and/or if there’s a way to bubble the event from component to actor on up the chain.

3. Also, I’d like to understand why PIE is different than standalone (it’s a bit of a bummer when it works in PIE but then mysteriously stops in standalone).

Any insights or advice will be very gratefully received. Thanks!

2 posts - 1 participant