Get Biome at Player Position

beginner faq

Voxel Play 3 · Troubleshooting & FAQ

Use the GetBiome method to get the biome at any given position or based on altitude / moisture levels:


public BiomeDefinition GetBiome (float altitude, float moisture);

public BiomeDefinition GetBiome(Vector3d position);



Additionally, the method GetTerrainInfo can be used to get information about terrain at any position:

public HeightMapInfo GetTerrainInfo (Vector3 position);

This method returns a HeightMapInfo struct with the data associated to the position:

    public struct HeightMapInfo {
        public float moisture;
        public int groundLevel;
        public BiomeDefinition biome;
    }

- moisture: a value in the 0..1 range.

- groundLevel: an integer value that represents the altitude of the terrain in world space.

- biome: the biome found at that position.


Example code:

VoxelPlayEnvironment env = VoxelPlayEnvironment.instance;
Vector3 playerPosition = VoxelPlayPlayer.instance.GetTransform().position;
HeightMapInfo terrainInfo = env.GetTerrainInfo (playerPosition);
Debug.Log ("Current biome is " + terrainInfo.biome.name);