Why the value of caseswitch can't change ?

when I touch the gameobject, the switch value cannot change. caseswitch = 0

// Update is called once per frame
void Update()
{
    gameObject.transform.position += new Vector3(0, -0.02f, 0);
    ammo2time += Time.deltaTime;
    
    switch (caseswitch)
    {
        case 0:
            break;

        case 1:
            if (ammo2time > 0.30f)
            {

                Vector3 Bullet_pos = Ship.transform.position + new Vector3(2, 0.1f, 0);

                Instantiate(ammo2, Bullet_pos, Ship.transform.rotation);

                ammo2time = 0;
            }

            break;

        default:
            break;
    }
}
void OnTriggerEnter2D(Collider2D col) 
{
    if (col.tag == "plane") 
    {
        Destroy(gameObject); 
        
        caseswitch = 1;
    }

}

You’re destroying the gameobject before you try and change your variable caseswitch. When you destroy the gameobject that holds the script, it can no longer run. You need to do the destroy function AFTER “casesswitch = 1”

void OnTriggerEnter2D(Collider2D col) 
 {
     if (col.tag == "plane") 
     {
         caseswitch = 1;

         Destroy(gameObject);
     }
 }

EDIT: Reading a bit more into it, I don’t quite get why you’re destroying your gameobject. If you destroy it, you’ll never get to use the variable you just changed. The switch statement in your update() won’t ever do anything.