Get current biome of a character
I struggle to find some example of how to get a biome name or its id. The game reports the current biome of a player in a log file and to steam's rich presence system but i can't figure out what functions i should call to get that info.
Ultimately i want to get a biome not of a player but of a lizard doggo when it spawns. But i welcome any tips and suggestions on this matter.
Ultimately i want to get a biome not of a player but of a lizard doggo when it spawns. But i welcome any tips and suggestions on this matter.
26 Replies
Solution
Never used it, but maybe try
UFGMapAreaTexture::GetMapAreaForWorldLocation
I haven't used the system much, but I think there are volumes placed in the world that are used to define what map area you're in. I think we left on in ExampleLevel? you can probably check collision with those volumes to find out where you are
There is a FGMapAreaTexture somewhere that looks like this when decompressed (the colour values came from the map area texture itself, but are only used when painting it). Each colour is a different "biome" (map area, IIRC)

Not sure what that is used for, but it seems to at least be used for rich presence and maybe some music stuff. I haven't checked if there are volumes, there's likely some
Hmm, that texture is probably created at runtime from VolumeMapAreas and it's probably used by the rich presence system. Normalizing player's location and sampling this texture using UV coordinates is probably faster than iterating over every area. Not that i know how to get the areas anyways, they are placed in the level itself and i have no idea how to extract such data.
GetMapAreaForWorldLocation
function sounds like exactly what i'm looking for, so i'm trying to figure out how to access it. It's not exposed to blueprints and an access transformer BlueprintCallable=(Class="/Script/FactoryGame.FGMapAreaTexture", Function="GetMapAreaForWorldLocation")
didn't help either.
Trying to learn how to mod with C++ right now, i think i need to create a blueprint function library. However, Visual Studio doesn't seem to cooperate and it doesn't see any of the UE headers. Regenerating project files, restarting VS, updating VS didn't help, in fact it broke it even more, at first it didn't see UE includes only in my mod, but now it doesn't see them even in MAM Tips mod that i downloaded as an example (it worked fine before). Even funnier, it seems to forget V5 version of the engine exists. despite knowing about Unreal5_3
on the previous line... I hate C++. 😦

It's not created at runtime
Alternatively i can just import this texture and sample it myself...
Where did you get it?
It's not a texture per se, one sec
Should be something along the lines of
FactoryGame/Content/FactoryGame/Interface/UI/Minimap/MapAreaPersistenLevel/MapareatexturePersistentLevel
Oh, this one! I saw that it was 1x1 pixel and decided it's not what i want. It didn't occur to me that it's just a stub.

It's not a texture per se
It's inside the FGMapAreaTexture, stored as indexed colours
wait, no, not this one
this one, it doesn't have a stub in the UE project

I made this thing a while ago to dump and compare map area textures from the currently running level (to compare ExampleLevel against the game's level): https://github.com/Th3Fanbus/Th3MapAreaDumper
There is a Python script that interprets the JSON I generate, but could be adapted to work with FModel
Alternatively, SignpostMarv made this (which takes FModel's JSON as input): https://github.com/SignpostMarv/MapareatexturePersistentLevel.json-parser
I'm not sure it's possible to get the map area texture for a specific location that isn't around the player. I see functions in
AFGGameState
and AFGPlayerController
for getting current or visited areas
Well, actually. You could probably get all of the subclasses and just iterate through them
But that would be cpp as wellIsn't the map area texture global?
There's only one
What there may be multiple of are map areas
Ah, true
Surprising there isn't some static method to just get the texture
There has to be one because I know I've used it
Ah, I think I get it through the minimap capture actor
Or whatever I did here
MapAreaTexture is available in BP but it doesn't have any methods or variables exposed

You might have to make a BP Function Library in C++ to use them
I'm afraid so 😦
It's not too bad once you've done it a couple times
Getting area name for the player turned out to be pretty simple btw, but i need it not for the player
(not sure this is the best way to get the controller)

I think you can also use the minimap capture actor for stuff
(not sure this is the best way to get the controller)For now it should be fine
Holy moly it worked.

Thank you, everyone!
Extra note: it takes some time for the MapAreaTexture to start working. For about 2 seconds after loading a save it will return
null
for any requested coordinates.
My solution is to check if returned MapArea is valid and if not then call Delay and loop back to try GetMapAreaForWorldLocation again.