I want to have several static values that do not change between different objects of the same blueprint. For example - unit build cost. Would it be possible to have something like this accessible from a blueprint class variable (the purple type) and not object reference?
Blueprint does not support static variables as well global variables, you would need to make single global object to hold such variable or use existing one (like GameMode class) or use other method of containing unit data. In C++ itās easier, you not only can use static variables, you can access variable defaults via default object in UClass (thats what you see as purple type in blueprint).
I think ability to get class defaults in blueprint is great idea for suggestion in feedback forum
alright thanks
Wow, thatās - strange.
So if I have a class which as a property like ānameā I am not able to access this without creating an instance first, getting the property and then destroying itā¦? Really?
Well if you want to access defaults you can do that via CBO, which if iām not mistaken support to access it via blueprint will be officially (since you can make it available to blueprint easily via C++) added in 4.9
You can do that now in the 4.9 preview I think.
a little hack if you just need variables to be readable from everywhere:
create a macro library and define a macro with just outputs for those values
Iām e.g. using that for having a central place to modify a global color scheme that needs to be accessible across different blueprints
instead, you can just define a getter function inside your C++ class.
UFUNCTION(BlueprintNativeEvent, BlueprintCallable, BlueprintPure, Category = āayy lmaoā)
MyType getMyStaticVarValue();
What I did was use a Data Table. Is there any better solution? I wish you could use something like a static variable and make use of inheritance.
EDIT: You can use getClassDefaults function using Blueprints!
i use get player characterā> cast to topdowncharacter ā> set (any variable of my character) and this is global variable is this solution fine? it works everything in my game