I’m new to Unreal and wanted this type of functionality: A new, community-hosted Unreal Engine Wiki - Announcements - Epic Developer Community Forums
Copypasted code (without using virtual) compiled just fine, but the event didn’t show up in the graph.
After searching in forums and discussions I was able to do it this way, but I don’t know anything about delegates so this seems kinda hacky to me:
//below #includes
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(EventName, AActor*, ActorParameterName);
//in the class
UPROPERTY(BlueprintAssignable)
EventName MyTestEvent;
//use like
MyTestEvent.Broadcast(GetOwner());
Why doesn’t BlueprintImplementableEvent work? What are drawbacks of using delegates as an alternative?
To use a BlueprintImplementableEvent you first have to declare it in code, example:
class ASomeClass...
{
UFUNCTION( BlueprintImplementableEvent, Category = "SomeCategory" )
void DoSomething( float Amount );
}
Then you can call the event from within the class…
void ASomeClass::SomeFunction()
{
....
DoSomething( 1.f );
....
}
Or maybe… from somewhere else in code…
...
{
ASomeClass* Thing = Cast< ASomeClass >( GetPawn() );
if( Thing )
{
Thing->DoSomething( 10.f );
}
....
}
And to define this event in Blueprints, you have to create a class derived from ASomeClass, then go to the ‘Functions’ section on the right, click the “Override” button (I think it appears when you mouse over), and click the event you created, and then it will show up in the graph!
Hope I helped!
That’s exactly what I tried to do, but the Event is not visible in the graph. What I’m trying to do is to have a c++ component (controller) in the blueprint and use the event defined inside this controller to send data to it’s owner blueprint when the event is triggered. The Blueprint event graph however doesn’t see my event if I do it this way. It works only with the delegate for some reason.
by default the event won’t show up in the graph until you click on Functions>Override and select your event. As long as the Blueprint is derived from the C++ class it should work.
If you still can’t get it to work, post the code for the class and the blueprint your trying to use the event in.