I was having this problem trying to figure out a way to get the Landscapes height map.
First I tried using #include "Landscape/Landscape.h"
but the library wasn’t found.
Then I added Landscape to the dependency list.
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore","AIModule","RenderCore","Landscape" });
Still nothing…
Then when I changed
#include "Landscape/Landscape.h"
to
#include "Runtime/Landscape/Classes/Landscape.h"
the code compiled, and my ALandscape pointer was getting assigned, but I could not access it because of an incomplete class error. I noticed that ALandscape
inherits from ALandscapeProxy
so I changed:
#include "Runtime/Landscape/Classes/Landscape.h"
to
#include "Runtime/Landscape/Classes/LandscapeProxy.h"
#include "Runtime/Landscape/Classes/Landscape.h"
and it worked. I have so far printed the name of my landscape i’m working with in the output log.
I used the following code to get the Landscape
UWorld* world = GetWorld();
ALandscape* landscape = nullptr;
if (world != nullptr) {
// Find the active landscape
TActorIterator<ALandscape> landscapeIterator(world);
landscape = *landscapeIterator;
}
if (landscape != nullptr)
{
FString lsName = landscape->GetName();
//landscape->LandscapeMaterial->GetName();
UE_LOG(LogTemp, Warning, TEXT("%s"), *lsName);
}
Late answer, but hope this helps. Still just barely dabbling in trying learning the Unreal engine.
-Mitch