Blueprint Derived classes not respecting bound Delegates

Hello,

This is a semi follow up to my previous post here:

I’ve managed to repo an issue with delegates when they are wrapped with a CDO flag check in the constructor e.g.

if (!HasAnyFlags(RF_ClassDefaultObject))

If the object is C++ derived the delegates stay bound, however if you create a blueprint derived from the C++ class the same delegates are not bound upon play.

I’m not sure what the root cause of this is but I have attached a test project that I used to reproduce the problem.

Test Project

To test:

  • Compile project in either DebugGame Editor or Development Editor
  • Open TestMap
  • Press Play
  • “The delegate was called” should appear on the screen
  • Change the default pawn class to BP_TestPawn
  • Press Play
  • Nothing will happen

Expected Result:
“The delegate was called” should appear on the screen.

If I remove the RF_ClassDefaultObjectcheck the problem doesn’t appear. Is this intentional behaviour? I figured you wouldn’t want to bind delegates to the CDO?

If there is anything else you need from me, please do let me know.

Thanks!

Hey Kanibel-

As long as the reference is self contained, binding a delegate to a class CDO is perfectly acceptable. If the constructor creates a component, attaches it, and binds something to it, then that should be fine (as you mentioned with removing the if statement). If it’s trying to reach something externally, that probably needs to be done in another callback which would be called on the instance.

Cheers

Thanks !