Why do I have 2 BeginPlay nodes on a Blueprint class Derived from a C++ class?
Hi all. I'm having an issue with semi-duplicate BeginPlay events made available in a blueprint that I derived from a C++ class. I made it fairly simple to start with so that I could test things as I built/learned and ran into this problem fairly early.
I created a C++ character controller with a UFUNCTION(BlueprintNative) tagged BeginPlay method. I expected to be able to simply override this in a derived blueprint, but now I have two versions of BeginPlay in my blueprint. At first I did not know this, so it took a while before I figured out why my blueprint wasn't behaving as expected. It was also a little trial and error to figure out which was the correct version of beginplay node to use.
Here are some screenshots to outline the entirety of the issue including both blueprint and C++ code:
This would be a non-issue if I only planned on working on the project myself, but I will be teaming up with other people who will be using blueprints derived from my C++ classes, so it would be helpful to have a solution.
My question is two-fold: Firstly, why am I getting two BeginPlay nodes? Secondly, what is the best way to expose only the C++ derived version to designers using only the derived blueprint?
Any insight is greatly appreciated.
Thank you in advance!
asked Aug 30 '17 at 04:16 PM in C++ Programming
I now have a more rounded idea of how all this works thanks to the page linked in @cmarston74's link provided as a comment on my original question: https://answers.unrealengine.com/questions/92332/overriding-beginplay-in-c-and-bp.html
It seems that C++'s begin play event and the blueprint BeginPlay event are not the same thing. To set up C++ BeginPlay to be overridden, the way I originally had it with an extra node is essentially the only way. Unfortunately that means that we'd end up with a duplicate BeginPlay node.
To manage this, its probably best to just not try to override C++'s BeginPlay directly and instead manage the situation with correct communication and workflow. Having two nodes with such similar names in blueprint will do nothing more than open the door for bugs, confusion and work interruptions.
answered Aug 30 '17 at 05:13 PM
Hey, you implementation is a little unusual. There's no need to make the BeginPlay_Implimentation. Override BeginPlay() with virtual void BeginPlay() override;
Now there's no need to do anything special to expose the Begin Play, your overriding it and adding your own functionality. When you make a blueprint derived from your class, the blueprint is a child class of your c++, so just calling the Parent:Begin play will act as the Super and work as you expect. Any code added in blueprint on begin play will be called after your parent c++ runs its begin play.
Just a note, im not even sure if you need to call the parent:BeginPlay when your parent is a cpp file. I think it will run without the Super.
Follow this question
Once you sign in you will be able to subscribe for any updates here