Collision detection with switch/case

Hi,
I’m trying to change a certain variable depending on what type of object my character is walking on. to do that I’ve used a collision function with switch/case.
Problem is - when my character walks on a certain object, it get stuck on that case statement and the variable doesn’t go back to its default value.

 function OnCollisionEnter(collision : Collision) {
 	var obj=(collision.gameObject.name);
    switch(obj){
    	case("EndingIndicator"):
    		Debug.Log("Ended");
    		break;
    	case("Bouncy_floor"):
    		isBounce=true;
    		break;
    	default:
    		isBounce=false;
    		break;

    }

 }

What am I doing wrong here? (I tried also naming the “default” object by name but that didn’t work)…

You should read a but how a switch works… The default case activates only when none of the other cases are met. Meaning in your code, if there is a collision, but the object is none of the specified names, it defaults. What you want is for the value to go false when there no longer is a collision.

Use onCollisionExit() for that.