How to spawn actors from blueprint in C++?
Can you help me?
asked Jan 29 '17 at 02:43 PM in C++ Programming
You need UClass pointer of blueprint class to use it with SpawnActor,
In C++ you can get UClass pointer of any class via static function StaticClass(). It impossible to get blueprint UClass like that because blueprints don't exist in compile time, you need to get UClass in runtime. You either do that with FClassFinder in constructor (it only works there), here example of it with widget blueprint (you can get path by right clicking asset and using "Copy Refrence"):
or there a lot simpler solution, make UClass* varable or TSubclassOf editable in property editor and then set in there, property editor will show both C++ and Bluepritn classes to choose. For example you make class which spawn something, you can make property which decides what it spawns.
answered Jan 29 '17 at 07:44 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here