[Question] BP - Accessing default values of a variables

Okay so I have a need for accessing the default value of the GroundSpeed variable in my Character Blueprint’s Movement Component. I cant seem to find a way to get or set default values anywhere in the Blueprint editor, so Im curious if anyone knows where I can find this or if its there at all 8)

Hi -

We plan on adding this feature once BP Comms are in. You’ll then be able to get the default object of anything, and then drag off and access any variable from it. The current hope is to get this in in time for the next beta, so you shouldn’t have to wait too long

No worries I have a work around using temp variables I set on BeginPlay and just call those back when required. I just wanted to make sure they wernt actually there and I was just missing them, thanks :slight_smile:

Was this feature added yet? How to use it?

Hello,

After you create a variable in your Blueprint, compile and then it will appear in your “Defaults” tab of the Blueprint Editor. From there you can set the default easily.

Cheers!

Sorry, I meant how to access a variable’s default from the event graph?

For instance: I modify a weapon’s damage from a BP function, then after some time, I want to set it back to whatever its default was (without having to save the default value in another variable).

In other words, the BP equivalent of:

GetClass()->GetDefaultObject()->SomeProperty

This was originally my question and this is what I meant also when I was asking because I was having to create new variables to hold the default values instead of being able to drag from a variable on the graph and access the default.

It could be possible to make some sort fo custom node that does this, I havent had the source until now so Im playing catch up on the c++ end.

Any news on this?

Nice, thanks for sharing!

I just added this BP function in C++ to solve this issue:

UObject* UMyBlueprintLibrary::GetDefaultObject(TSubclassOf<UObject> ObjectClass)
{
	return ObjectClass->GetDefaultObject();
}

Then you can access the default properties in graph just like normal properties. Be careful not to modify them though, I suspect bad things would happen.

Soooo I need to do this as well. A year later, has this been added? I couldn’t find any documentation on it.

It will be in 4.9:

Get Class Defaults node gives access to Blueprints’ values without having to create an instance

Sadly it doesn’t show many types of variables, such as SkeletalMesh, Material, etc: New 4.9 Get Class Defaults node doesn't have all the variables - Programming & Scripting - Unreal Engine Forums