Get default values of a class without actually spawning it

USING BLUEPRINTS

How do I access the default values of variables in an actor class without actually spawning the actor in the world?

Lets say I have some actor which causes some cost in game currency to spawn, I want to show a message to player if he can spawn it or not depending on how much game currency he has during the match, and for this I’ll need to get the cost of the unit which will be stored in the actor class’s variable.

I understand spawning the actor is equivalent to instantiating an object of class in C++ but then I will need to clean up the spawned actor after using its value and any begin play things would run causing problems.

So I want to get the variable value of the class without spawning it.

In UE3 unreal script you could do that as : Class ’ class name’.default.var_name

can I do something like that in UE4?

You can use ActorClass.GetDefaultObject()

Or you can declare your variable as static.

Sorry I meant to do it with blueprints

You ever end up finding a way to do this in BP?

This feature was introduced to blueprint in 4.9. For the info on how exactly to use it you will need to read the 4.9 Release notes :slight_smile: