Download

Delegate Binding when BP inherits C++ Class

So, I’ve been wanting to slap myself in the face quite a few times lately. I’ll create a C++ class first, set up components as properties, allow the BP editor to see it, and when I do things like delegating events in the constructor of the actor, sometimes it works, and sometimes it doesn’t. It drives me crazy.

After research, I found out that UE serializes constructors when using BP’s that inherit the class, so adding the delegate binding after the fact won’t work since it doesn’t get updated. Shucks.

I found more info at this link:

One of the comments in that thread says, “constructor is good for default, component initiation and delegate binding.”

But is that statement true if it works only if you bind it before creating the blueprint? It sucks to have to delete blueprints and re-create it. Is there a way to “refresh” or “reserealize” ? Or should delegate binding be defined on “PostInitializeComponents” or “BeginPlay”?

What way is preferred? I typically only see this in the constructor and sometimes in BeginPlay. What’s the community’s consensus?

Thanks for your help in advance!

I do all of my delegate binding in BeginPlay and have no issues.