Spawn blueprint based on name
I am using a custom server and really need a way to spawn classes/objects dynamically based on information from the server. I am fine with doing this in either C++ or Blueprint scripting, I just need a good way to do it. I know in C++ you can reference Blueprint classes directly but this is frowned upon. Is there any other way to do something like this?
asked Sep 07 '15 at 02:37 AM in Blueprint Scripting
If you want something more robust than just sending the string name across the network and spawning it that way, you can make a data table with ids you'd store on the DB that has references to the corresponding blueprints, which you can store int he data table as actual blueprint references and spawn them that way. Otherwise you can just send the string of the blueprint you want to spawn and spawn it.
You're probably making a bigger deal of the problem than it actually is, and that's ok. Don't be afraid of getting it working just sending the string of the blueprint reference and making it better later.
answered Sep 07 '15 at 03:08 AM
Build your client-server solution in a way to make use of FStringAssetReference
Server can handle these as strings.
On the client side, create AssetLoader as singleton or somewhere in your GameInstance (because there is only one per running game).
When client receives this string, get AssetLoader to load relevant asset. After that you can use it like any other asset. (eg you can spawn it as an actor in required location)
answered Sep 07 '15 at 03:17 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here