Is it possible to cast Actor to Bueprint Actor in C++ and return it to Blueprint?

For example I have C++ class AMyGameMode, which is inherited from AGameMode, and MyGameModeBlueprint which is inherited from AMyGameMode. The project is setup as having MyGameModeBlueprint as Engines GameMode class.

Can I write UFUNCTION which will return World->GetGameMode() object, which will be interpreted as MyGameModeBlueprint type object in blueprints, without any subsequent casts in blueprints, and without using blueprint macros.

No, because blueprints don’t exist physicly as C++ code, so it does not exist during compilation code in order to link it sonehow. You would need to make custom UK2Node class for that, which would auto cast the output pin (Same as curently Spawn Actor node doing, which is also custom K2Node).

You may heard about this, theres currently experiments in Epic, to make blueprint compile to C++ code, this may allow easier access to blueprint classes in C++, which could let create such a node, with standard function bind.

Wow, sounds cool but to complex for my task. I will research in custom UK2Node creation, but definitely would not use it in my project. Thanks man.

Blueprint to C++ is cool, but I think some form of declaration that this function actually return BlueprintDerivedClass, not this CppBaseClass, would be enough for my task.