Creating an event on an ActorComponent in C++ for Blueprints
What I want
I'd like to have actors in my scene who can react to a custom event I defined in C++. Small example the player stands next to a button and presses it. I want to fire the event from my C++ code and want to react to it in a blueprint.
What I did
I created a class, derived from UActorComponent, like that:
This is how I try to fire the event in C++:
The C++ side compiles without warnings or errors, the code is actually being executed.
I created a blueprint, consisting of a StaticMeshComponent and added my component to it:
What I expect
I expect the event to be available in the blueprint editor of my actor (similar to other events, like 'Event BeginPlay').
What actually happens
The event can't be found, independent of context sensitivity/search phrase:
What I tried
There are a lot of different answers to this question online, most of them rather old, and none of the answers helped me achieve what I want. For instance, I tried creating a dynamic, multicast delegate but wasn't able to register to the event in blueprint. No errors occured, it simply didn't execute when I used OnMyStuffUsed.Broadcast().
I also tried dragging "MyUsableObject" from the list of variables on the left side to see if the event is only available on the component object directly - didn't appear in there either.
I tried restarting everything, no difference.
If I missed something or I'm expecting things to work in a way they don't, please tell me.
asked Aug 19 '17 at 02:59 PM in C++ Programming
I just solved it myself. Using a DYNAMIC_MULTICAST_DELEGATE is the right way here, I think i simply connected it the wrong way. Here's how I did it:
My code looks like the following:
Firing the event:
Binding the event in Blueprint:
answered Aug 19 '17 at 03:43 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here