Get project settings gravity from BP?

I want to get the gravity of the project from a Blueprint, but can’t figure out how to do that.
I’ve read that in C++ you can do UPhysicsSettings::Get()->DefaultGravityZ.
Is there a way to do that in BPs?

If there isn’t a BP exposed function you can always create a BP library yourself.

.h

#pragma once

#include "Kismet/BlueprintFunctionLibrary.h"

#include "PhysicsUtils.generated.h"


UCLASS()
class UPhysicsUtils : public UBlueprintFunctionLibrary {
	GENERATED_BODY()

public:

	UFUNCTION(BlueprintCallable, meta = (CallableWithoutWorldContext))
		static float GetDefaultGravityZ();

};

.cpp

#include "PhysicsUtils.h"
#include "PhysicsEngine/PhysicsSettings.h"


float UPhysicsUtils::GetDefaultGravityZ() {
	return UPhysicsSettings::Get()->DefaultGravityZ;
}

The reason you can’t find the UPhysicsSettings in BP is because UPhysicsSettings::Get is not a bp accessible UFUNCTION. You could however again implement your own library method with a BP accessible UFUNCTION that executes UPhysicsSettings::Get

1 Like