Can I Spawn a BP from CPP?
Hi! So I've been trying to spawn in another CPP actor using my CPP actor manager. It works perfectly but the thing is that I do not specify many aspects of the actor at runtime in the CPP because I like to configure the settings in blueprint before using it. I would like to spawn in the blueprint instance of this actor.
How would I do that in CPP? Thanks a ton.
asked Apr 07 '18 at 04:43 AM in C++ Programming
Ofcorse, first you need to realize that blueprint is a class same as C++ class.... so yes that means every blueprint as any other class has it's own UClass which you can do SpawnActor, it's also importent to understand that same as you extend class C++, blueprint also extends class including C++ once. Go see "Class Viewer" in Windows->Devlopment Tools->Class Viewer and search your blueprint there and you will be able to see class relation tree of your blueprint, it should open your eyes. Only limitation is you can't use blueprint-made object directly as type in C++, as compiler don't know how to interact with virtual classes and objects like blueprints. you need to use most common C++ class related to blueprint insted.
There 2 ways to get UClass of blueprint:
1 option is most safest since referencing assets direly in C++ may cause error in packaging, aspecially if C++ code is only thing referencing to asset, then it is not packaged and cause error in packaged game.
answered Apr 08 '18 at 08:44 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here