Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

BlueprintNativeEvents cannot be made virtual, an error message suggests otherwise.

  1. Create a class. Doesn't particularly matter what type of class, as long as it can have UFUNCTIONs defined inside of it.

  2. Define a UFUNCTION(BlueprintImplementableEvent) virtual void DoAThing();

  3. This fails, with an error message suggesting that you should use BlueprintNativeEvent instead. Change it to BlueprintNativeEvent.

  4. This fails, with an error message stating that BlueprintNativeEvents can't be virtual.

This means they can't be overridden in C++, unless Unreal does some seriously stupid language hacking, in which case this should be documented, but here are the entirety of the docs pages on BlueprintNativeEvent:

This function is designed to be overridden by a Blueprint, but also has a native implementation. Provide a body named [FunctionName]_Implementation instead of [FunctionName]; the autogenerated code will include a thunk that calls the implementation method when necessary.

and BlueprintImplementableEvent:

The function can be overridden in a Blueprint or Level Blueprint graph.

Nothing about virtual not being necessary to make it overrideable in C++, nothing about any way to do both... just nothing.

So, in short, either the error messages are misleading -- which is a bug, hence this being a bug report -- or the documentation needs to be updated -- which I'm considering a bug so I don't need to file this in two separate places, which would probably just be irritating for everyone. Either that or I'm missing some annotation which allows a method to be overridden in both C++ and Blueprints, without having to make separate, extra methods to wrap both and do some fancy logic of my own, since the only reason I'm using Unreal instead of writing everything from scratch is to get that kind of repetitive stuff taken care of for me.

Product Version: UE 4.16
more ▼

asked Jun 23 '17 at 06:24 PM in Bug Reports

avatar image

28 1 3 6

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Hey nic-hartley-

If I understand correctly you are trying to create a function that can both be overridden in a class blueprint as well as a child C++ class, correct? This is possible with the BlueprintNativeEvent specifier and _Implementation functions. Consider the following declaration:

 UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category = test)
     void TestFunction();
 void TestFunction_Implementation();

The BlueprintNativeEvent is what allows the function to be overridden in blueprints and the _Implementation is the default code that is called if it is not overridden in blueprints. To be able to override this in your child class, you will need to make the _Implementation() function virtual ( virtual void TestFunction_Implementation();). In your child class you would have:

 UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category = test)
 void TestFunction();
 virtual void TestFunction_Implementation() override;

This would allow you to implement the function both in your parent and child C++ class, and override them (independently) in their respective blueprints.


Doug Wilson

more ▼

answered Jun 30 '17 at 08:17 PM

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question