I want to access some Interger value (and maybe others) that is stored within a Class. But when i can only find a node to “get that int value” from a reference of that class. but i do not actually have an instance of it yet.
I assume you mean accessing default values of variables, like name or default stats of things. There no way to do that in blueprint as i know, but it’s possible to access default variables of class in C++ by calling GetDefaultObject() from UClass* of specific class. You can try to expose it from C++ to Blueprint by making this static function:
h:
UCLASS()
class UMyNodes : public UObject
{
GENERATED_UCLASS_BODY()
UFUNCTION(BlueprintCallable, Category="My Nodes")
static UObject* GetDefaultObject(UClass* ObjectClass);
}
cpp:
UObject* UMyNodes::GetDefaultObject(UClass* ObjectClass)
{
return ObjectClass->GetDefaultObject();
}
This will output object refrence with default varables in it without spawning a object.
But accessing those with just class refrence would be cool too, post a suggetion on feedback forum
Hey, thank you for the answer:)
Though i just started using ue4 (~1week by now) and i did not have any contact with C++ yet at all. This leads to me having no clue about how to implement a C++ function into BP. I have been actively searching google, unrealwiki and this answerhub, but i did not find anything that helps me.
I tried to make the code you posted above work by:
->Adding Code to Project
→ Blueprint Function Library
→ name it “MakeObjectReference”
→ copy paste the code above.
now i have no idea what to do next so i can see the function in my BP’s. Last time i have tried to make something work in C++ in Visual Studio for my UE Project it messed up the whole project and i wasnt able to open it anymore:(.
Maybe i am missing something?
(does that function above make a node like following? :
input custom Object Class → output custom object instance reference with default values?)
Did you compiled the code?
when i try to it shows me a dozen of complie errors
Ok copy paste the code and errors, maybe use http://pastebin.com/ so this page won’t turn in to mess