What is direct C++ equivalent to “expose on spawn” behavior found in blueprints?
In blueprints “expose on spawn” allows passing values into blueprint’s construction script, (as I understand it) technically before object is added into scene.
In my project I have (C++) “init” method (which I call manually) for this kind of thing, but as far as I can tell, that one will be called AFTER object has been added into scene.
There is “OnConstruction” method that can be overrided, but its only parameter is FTransform, so I can’t really pass values through it.
So, what would be an equivalent to “Expose on spawn” behavior found in blueprints.
This would expose the C++ variable in the spawn node within blueprints, but if you need to know a variable value in C++ before you can finish spawning, you’ll need to use deferred spawning.
That ain’t it. I’d like to know how to pass parameters into object during construction in the manner similar to “expose on spawn”. I’m not looking for a way to expose variables to a blueprint. After all, in unreal construcor only sets default values and isn’t used to pass parameters into objects.
Use SpawnActorDeferred to initialize the variables before spawning the object with FinishSpawningActor although there isn’t any way to pass in the parameters within the spawn call as far as i can tell.
Edit : BeginDeferredActorSpawnFromClass is the way to go since SpawnActorDeferred has been deprecated.