Download

UFUNCTION BlueprintImplementableEvent issue

Hey,
I am totally new to unreal engine, so it might be my mistake (I am really sure, its my mistake :P)
I try to use a function which i declare in my c++ script in editor. Thus I use the UFUNCTION(BlueprintImplementableEvent, Category=“Combat”) macro. After this, I created a new Blueprint class and opened the blueprint editor. And there I am…
I am unable to find the written function, so I tried a bit around and declared the function as const (I looked into the ACharacter class, because the only selectable function in editor was the “CanJumpInternal” method and this function is const).
So my question is, is this correct? Did I made a mistake? The example under Introduction to C++ Programming in UE4 | Unreal Engine Documentation has no const declaration, but also explains not very much about this topic.

BlueprintImplementableEvent requires a virtual function doesn’t it? I’m looking back at my code where I’ve used it and they’re all virtual (and I know I’ve called them in Blueprints). For instance, one of mine looks like:

UFUNCTION(BlueprintImplementableEvent, Category=ContextAction)
virtual void Execute();

It seems I do not need a virtual declaration. I think the engine calls an internal version of my function (there has to be an implementation for my function). At least my specific problem works without the virtual.
But I am unable to see my function in the editor without the const declaration (declared as virtual or not).

My engine version is 4.7.6

TSEmmett is correct. You implement blueprint events (both [FONT=Courier New]BlueprintImplementableEvent and [FONT=Courier New]BlueprintNativeEvent). Here’s an example from our game:

In our header file, we declare this:



	UFUNCTION(BlueprintNativeEvent, Category="World Action Item")
	void OnActionTriggered();


And our implementation looks like this:



void AWorldActionItem::OnActionTriggered_Implementation()
{
    // Logic needed when blueprints don't implement the event. Can be empty.
}


i’m not sure what the best practice is in this regard, but we usually don’t make our events BlueprintCallable. Instead, we declare another method to actually fire off the event, like so:



	UFUNCTION(BlueprintCallable, Category="World Action Item")
	virtual void RemoveHUDItemsIfNecessary();


In our case, we want to trigger a sound whether the blueprint implements the event or not, so our implementation looks like this:



void AWorldActionItem::TriggerAction()
{
	if (OnTriggeredSound && OnTriggeredSound->IsValidLowLevel())
	{
		UGameplayStatics::PlaySoundAtLocation(this, OnTriggeredSound, GetActorLocation());
	}
	OnActionTriggered();
}


We do get warnings in 4.7.6 with [FONT=Courier New]BlueprintNativeEvent, however. It doesn’t seem to affect the program, but it does throw some junk into the

Have you tried restarting the editor after creating the BlueprintImplementableEvent in code and compiling?
I always have the problem (and I suppose it is not just me) that after creating a BIE I need to restart the editor for the function to show up in Blueprints.
Although that would probably not explain why it does work if you make it const.

If you just want to call a function defined in C++ from a blueprint, you should use BlueprintCallable in your UFUNCTION macro. From the wording of your post this seems to be what you want. But, if you want to override the function in a blueprint to change it’s behaviour you can use BlueprintImplementableEvent, or BlueprintNativeEvent if you want to have a C++ implementation as well as a blueprint one.

See the documatation here: UF:: | Unreal Engine Documentation for short descriptions of what each specific is used for.

Ok, thanks for reply, but I think I have to do some better explaining.
I know the effect of BlueprintImplementableEvent, and that´s exactly which I intend. So, what did I do?

I created over the editor a new subclass of ACharacter and tried to add a function, which I must override in the blueprint. This is only a test case to become more familiar to the engine and c++ part.
After that I created a new Blueprint class for the c++ class. And here is the problem. I am unable to select my function, unless it is declared as const.
Editor restart doesn´t help.
Blue.png

I find my function here (the const version). Is this correct, or should I search at an other position in the e

Try right clicking in the main EventGraph and start typing Event. You should be able to create an Event YourEventName node (like Event Begin Play), an entry point where you can implement your function. I think for events without return type this is the way to override/implement them.