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"

overriding beginplay in c++ and BP

I have a subclass of actor written in c++, which needs to perform some operations on BeginPlay. That's easy enough to do in c++, but I want any blueprints that inherit from this class to be able to implement this event as well (and call the parent BeginPlay if required).

In order to try and solve this, I added "UFUNCTION(BlueprintNativeEvent)" ahead of my "void BeginPlay()" definition in the header file, and changed the code in my cpp file to BeginPlay_Implementation(). However, this doesn't work, because now I have two BeginPlay functions defined. If I change the category of the UFUNCTION, it works, but this seems like a hack.

Can anyone give me an example of code where the BeginPlay_Implementation() function is called AND the Event BeginPlay [blueprints] being fired?

edit: Turns out I wasn't calling Super::BeginPlay() in my c++ code.

Product Version: Not Selected
more ▼

asked Sep 02 '14 at 11:12 PM in C++ Programming

avatar image

529 20 21 61

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

1 answer: sort voted first

The Blueprint event is actully ReciveBeginPlay() and it called in BeginPlay in AActor class. But i thing what you looking for is how to call Super::BeginPlay() in blueprint, you can do that by right clicking the event end there should be option to create call to paret and its gonna create orange node where you can call event in parent, its equivlent os Super call.

more ▼

answered Sep 03 '14 at 01:08 AM

avatar image

36.6k 932 169 1111

avatar image veggiesaurus Sep 03 '14 at 07:11 AM

Unfortunately, RecieveBeginPlay is only BlueprintImplementable, so I can't override RecieveBeginPlay_Implementation(), which is what the blueprint "Call to parent" is looking for. Turns out the whole problem was that I wasn't calling Super::BeginPlay() in my c++ class, so AActor::BeginPlay (and hence RecieveBeginPlay) was never reached. Moral of the story: always call your supers. Now both the c++ code and blueprint code fires, even without a call to parent.

Now the hypothetical question is: Is it possible to OVERRIDE the BeginPlay function completely in blueprints?

avatar image Shadowriver Sep 03 '14 at 07:18 AM

No, because BeginPlay is not blueprint event to begin with, 2nd it won't stop beginplay being called nativly where blueprint has 0 control over code flow.

avatar image veggiesaurus Sep 03 '14 at 07:45 AM

Ok, thanks for clarifying :)

(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