Terrian 3D: Doing in game actions based on the texture the character is standing on

Enhance gameplay by triggering actions based on terrain textures. Use Terrian3D to fetch texture IDs at the player’s position:

get_texture_id() returns a Vector3 containg Vector3(base texture id, overlay id, blend value).

    @export var terrian:Terrain3D)
    func _physics_process(_delta: float) -> void:
        var texture_pos: Vector3 = terrian.data.get_texture_id(PlayerManager.get_player().get_position())
        print_debug("Texture ID: {0}".format([texture_pos]))

        var base_texture_id = int(texture_info.x)  # Base texture ID (e.g., 1 = Grass, 2 = Dirt, 3 = Sand)
        # base_texture_id is the index of the texture in the terrain from the Terrian3D inspector
        # in my case 1 is grass, 2 is dirt, 3 is sand
        print_debug("Base Texture ID: {0}, Overlay ID: {1}, Blend: {2}".format([base_texture_id, texture_info.y, texture_info.z]))

        match base_texture_id:
            1:
                print_debug("Grass")
                # Trigger grass-related actions
            2:
                print_debug("Dirt")
                # Trigger dirt-related actions
            3:
                print_debug("Sand")
                # Trigger sand-related actions

Use this to adjust movement speed, trigger sounds, or create particle effects for immersive gameplay. It’s simple yet powerful!