Get class default values from Class variable?

I have a C++ class that stores an array of BP classes. In blueprint I want to iterate through that list of classes, spawn off an actual instance, and then set the values on that instance to be equal to those of the classes defaults.

Essentially, I have defined a BaseItem class, which in the editor a designer will subclass with a blueprint, then set the defaults appropriate for a specific item. Then all those blueprint classes are added to an array property on an “Item Manager” which at runtime should instance them all out as I said above. But I can’t figure out how to get the values set by the designer in the BP class.

In searching around I found a statement from Epic staff saying that they were adding the ability to get the CDO in Blueprint, and that it should be available in a beta soon. That note was a year old, so surely it is in now? I can’t figure out how to do it though.

I also would like this implemented in Blueprints. While I have learned far more about blueprints while attempting to get a component rotation from a camera in another blueprint, the fact I cannot just grab a ‘class’ and get the default values assigned makes it so I will end up hard coding each blueprint with the static value I assign the camera.

I suppose a work-around would be to include all these settings on the gametype, then place an instance of the gametype on every level… it means I’d also have to pull values to said camera blueprint and alter the gametype blueprint when dealing with camera rotation.

The new feature works great in 4.9, just no idea what that will be finaled.

I know this is super old, but it came up in my search for the same issue.
The “Get Class Defaults” node does the trick. I recommend using it with read-only properties, allows you to extract info from the class before spawning it.

1 Like