I’ve built a custom pawn in C++, and would like to add additional components and logic to it via a blueprint. For example, I would like to handle the kinematic side of things in C++, but handle some visual effects using blueprints, for faster iteration. Is this possible? I know I can extend my custom pawn as a blueprint, but how do I think specify the default blueprint in my C++ custom game mode? Do I have to create a blueprint game mode?
You can make a reference to it BlueprintEditable in your C++ class header, then assign it from there in C++.
I’m forgetting the pointer type right now, someone else is going to have to chime in on that.
You can also grab blueprint class in C++ with this in constructor (it won’t work anywhere else):
UClass* BPClass; static ConstructorHelpers::FObjectFinder<UBlueprint> BPObject(TEXT("Blueprint'Path/To/Blueprint'")); if(BPObject.Object != NULL) BPClass = BPObject.Object->GeneratedClass;
Then you can spawn BP object from UClass pointer BPClass
Also with ConstructorHelpers::FObjectFinder<T> you can grab any asset not only blueprints butalso for example meshes for MeshComponents for actor
Boy that was fast! Thanks, I will look into it. For now, just creating a blueprint of my custom game mode allowed me to select it, as predicted It’s wonderful that there’s such parity between C++ and blueprints!
For what it’s worth, this is actually how we have our player pawn setup in Fortnite so far. We have a base, native C++ class that our engineers will add functionality to, but the version of the pawn we use in game is a blueprint extending from that native class, so we can quickly iterate on content changes, etc.
Glad to see I’m making sensible design decisions then!
I’m a bit late to the party but have been looking into creating a base class in C++ and deriving it several times with Blueprints, much like:
I’m able to use ConstructorHelpers::FObjectFinder, grab the class from the Blueprint, and use SpawnActor … but this limits me to the constructor! I could manually find each one in the constructor and store the class for later but that seems silly.
Billy Bramer - Could you give a bit more information about how you grab the class from the Blueprint and spawn the actors? Thanks!