Download

Blueprint instances as C++ variables (for Gamemode,PlayerController,etc)

Hi. I want to know if is possible to store a blueprint actor asset instance in a C++ variable as any other asset. I am trying to do it same way as non blueprint assets but is not working.

For other assets I just use LoadObject(nullptr, TEXT(“location and name’”));

Basically I have a PlayerController, Gameinstance and GamemodeBase done in blueprints and I want to have a C++ Class with those 3 blueprints stored in local variables.

I Know i can get my gamemode with:

GetWorld()->GetAuthGameMode()

But I can’t Cast and store in a local variable because can’t access to its Blueprint class.

Possible?

No, native can’t create variables with types that exist only in content (ie Blueprints). The general solution here is to make a more specific subtype, say MyPlayerController, derive your blueprint from that and then make all your native references to MyPlayerController instead of PlayerController (or whatever type you’re making more specific).

Hey! Thanks for your reply.
So is not possible to do this in C++ if MiGamemode is a Blueprint?

Correct. You’d need a type that is known by C++ to do that cast in native.

1 Like