Download

Working With Marketplace Blueprints in a C++ Project

I’m a developer and I prefer C++ over blueprints but I’ve found several items on the Marketplace that I’d like to use in my project that are written in blueprints. I’ve done some digging and found some responses to this but I just want to make sure I’m understanding what needs to be done and see how others are tackling this.

I’ll use Ultra Dynamic Sky as an example. Let’s say I want to set up some dynamic weather logic in C++ which would involve changing some variables in the UltraDynamicSky blueprint, such as lowering the intensity of the sunlight, increasing the cloud density, etc.

I’ve read that things can easily get out of whack if you change a variable type or something in a blueprint and forget to change it in the code or maybe have two variables with the same name, etc., and that it’s better to define your variables in C++ and make them accessible to the blueprint.

So is the best option in such a case to redefine the variables in C++ and remove the definitions from the blueprints and change them to use the variables you defined in C++? And if so, are there any tools, like class viewers or whatever that makes this process any easier? Or is there a better way?

You could make a base class in C++ for those blueprints and then reparent the blueprints to the corresponding C++ base clases. Then you can fire BlueprintImplementableEvents in the blueprints to do whatever you want to do.
This way you won’t need to redefine variables and methods, it’s kind of a bridge between your game in C++ and the Ultra Dynamic Sky blueprints.

If you change anything on the pure Blueprint pack then later you won’t be able to upgrade when author release new versions.
The easiest way to tackle this is create another BP through C++ with some BlueprintNativeEvent functions. Whenever your C++ code need to execute anything from the Blueprint world you call one of those Events, linking them to the third-party Blueprint functions later.

Thanks! The google has failed to provide these options.

I can’t believe I hadn’t considered this. If I make additions to a blueprint, are they overwritten with an update?

I don’t think you would want to use stock Blueprint packages in your game project to begin with. They are neither optimized for your game design nor performance in general. The “Ultra Dynamic Sky” in example has a pretty complex material and blueprint system. If you still want to use them, there is nothing wrong with keeping the Blueprint variables rather than replacing them with C++ ones, which can be a lot of work. For the first argument you would also normally not worry about updates on the marketplace assets (which are also usually not updates but just opening the asset in a new engine version). But just for funsies you can actually call blueprint functions from C++ without Blueprint implementable events, there is FindFunction(FName(“MyBlueprintEvent”)) and ProcessEvent(MyFunction, &MyInput)