Get the abolute game path

I’m using FPaths::GameDir() and it’s giving me the result “…/…/…/…/…/…/Users/wleu/Desktop/Stash/Projects/PSIF System/”. Is there a function to get that path starting from the drive (i.e., “C:/”) instead of some weird relative path.

Theres 6 folders listed and six “…/” listed, I’m guessing it’s starting at “PSIF System”, going all the way back down to “C:/” and then back up to “PSIF System”, which IMHO seems inefficient and bizarre.

You should be able to get the full path with CollapseRelativeDirectories or ConvertRelativePathToFull:

FString RelativePath = FPaths::GameDir();

UE_LOG(LogTemp, Warning, TEXT("RelativePath: %s"), *RelativePath);
GEngine->AddOnScreenDebugMessage(-1, 60.0f, FColor::Red, RelativePath );

FString CollapsedPath(RelativePath );
bool bCollapseSuccess = FPaths::CollapseRelativeDirectories(CollapsedPath);
FString CollapsedSuccess = bCollapseSuccess ? FString(TEXT("TRUE")) : FString(TEXT("FALSE"));
UE_LOG(LogTemp, Warning, TEXT("CollapsedPath: %s"), *CollapsedPath);
GEngine->AddOnScreenDebugMessage(-1, 60.0f, FColor::Emerald, CollapsedPath);
UE_LOG(LogTemp, Warning, TEXT("CollapsedSuccess: %s"), *CollapsedSuccess);
GEngine->AddOnScreenDebugMessage(-1, 60.0f, FColor::Orange, CollapsedSuccess);

FString AbsolutePath(FPaths::ConvertRelativePathToFull(Directory));
UE_LOG(LogTemp, Warning, TEXT("AbsolutePath: %s"), *AbsolutePath);
GEngine->AddOnScreenDebugMessage(-1, 60.0f, FColor::Cyan, AbsolutePath);

Arg! I was using FPaths::ConvertRelativePathToFull(), and that turns out to be what I needed, but I didn’t see the overloaded version that only took one parameter. Thanks!


Simple as that! Only via blueprint.