x

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"

How to overide BlueprintNativeEvent method from base class?

Hi!

How can I override a method from a base class (in c++) that is declared as a BlueprintNativeEvent? I tired to add "_Implementation" to the end of the name of my new method override with no success, (exactly the same signature as the base class except the class it belongs to of course).

I guess I'm just using it wrong but couldn't find any further information about this issue. So how can you create an override for a base class method defined with BlueprintNativeEvent?

Thanks in advance!

Product Version: UE 4.8
Tags:
more ▼

asked Jun 12 '15 at 08:26 PM in C++ Programming

undercover gravatar image

undercover
625 108 91 117

(comments are locked)
10|2000 characters needed characters left

2 answers: sort voted first

Hello, undercover

Please make sure that your function was appropriately implemented in the base class:

 //.h file
 UFUNCTION(BlueprintNativeEvent)
 void Foo();
  virtual void Foo_Implementation();
  
 //.cpp
  void ACustomActor::Foo_Implementation()
  {
        // needed functionality
  }

Thus, you'll be able to override it like this:

 virtual void Foo_Implementation() override;

Also please don't forget to define the function in .cpp file of the derived class:

 void ADerivedActor::Foo_Implementation()
  {
       // needed functionality
  }

Hope this helped!

Cheers!

more ▼

answered Jun 13 '15 at 01:42 PM

Andrii Melnyk gravatar image

Andrii Melnyk
1.6k 57 10 103

undercover gravatar image undercover Jun 13 '15 at 04:13 PM

Hi!

I'm trying to override FindPlayerStart from the AGameMode.

I get the following error message: "error C3668: 'AMyGameMode::FindPlayerStart_Implemention' : method with override specifier 'override' did not override any base class methods"

My (MyGameMode.h) header looks like this:

 AActor* FindPlayerStart_Implemention(AController* Player, const FString& IncomingName) override;

My (MyGameMode.cpp) source like this:

 AActor* AMyGameMode::FindPlayerStart_Implemention(AController* Player, const FString& IncomingName)
 {
     return nullptr;
 }

I'm trying to make the transition from 4.7 to 4.8 but can't get those previous virtual methods to work anymore. Can you see what I'm doing wrong?

kirdaybov gravatar image kirdaybov Nov 10 '16 at 07:23 AM

Is this still usable in 4.13? I try and I get the following:

 3>C:\_insomnia\Source\Insomnia_v2\Common/Thing/Time/ThingTime.h(47): error C2535: 'void UThingTime::Foo_Implementation(float)': member function already defined or declared
 3>  C:\_insomnia\Source\Insomnia_v2\Common/Thing/Time/ThingTime.h(24): note: see declaration of 'UThingTime::Foo_Implementation'
BrUnO XaVIeR gravatar image BrUnO XaVIeR Mar 24 '17 at 02:08 AM

You will get that error if you use GENERATED_UCLASS_BODY() macro instead of new macro GENERATED_BODY().

(comments are locked)
10|2000 characters needed characters left

Please note that you should name your method FindPlayerStart_Implementation instead of FindPlayerStart_Implementation. It is most likely that the error occurs because methods' names don't match in base and derived classes.

Changing _Implemntion to _Implementation should fix the problem.

more ▼

answered Jun 14 '15 at 11:02 AM

Andrii Melnyk gravatar image

Andrii Melnyk
1.6k 57 10 103

undercover gravatar image undercover Jun 14 '15 at 12:46 PM

That was a stupid mistake. Thanks a lot for pointing it out, now it works like a charm =)

(comments are locked)
10|2000 characters needed characters left
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