Break Doesn't Working

With this code i am finding the texture that my player is walking on. When my player move to other texture i want to change a bool to false and stop. But it’s always working. Always making that bool false. How can i fix this?

void Değiş()
{
int terrainTextureIndex = terrainDetector.GetActiveTerrainTextureIdx(transform.position);

    switch (terrainTextureIndex)
    {
        case 0:
            çalıştı = false;
            break;               
        case 1:
            çalıştı = false;
            break;                
        case 2:
            çalıştı = false;
            break;
        case 3:
        default:
            çalıştı = false;
            break;
    }
}

Well, it seems you need to keep track of the old texture index and compare it with the new one. In the code you posted you’re setting variable to false no matter what.

So, in pseudo code:

at the top of your code, before any function, set:

int old_terrainTextureIndex = -1;

Then check to see if you enter a new texture before you do anything else

if ( terrainTextureIndex != old_terrainTextureIndex ){ 

     // then do what you want to do and also 
    old_terrainTextureIndex = terrainTextureIndex; 

}