Changing physics material at runtime not working

Here’s the relevant snippet of my code:

	var bounce = PlayerPrefs.GetInt("ExtraBounce");
	var setBounce = collider.material.bounciness;
	switch(bounce){
	case 1: setBounce = 0.1;break;
	case 2: setBounce = 0.2;break;
    case 3: setBounce = 0.3;break;
    case 4: setBounce = 0.4;break;}

I want to change the bounciness of this object based on the player preferences.

Thanks for the help,

Adam

sorry, this is REALLY LATE:

function Update()
    {
    //if you left click the mouse the bounce will increase
    if (Input.GetButtonDown("Fire1"))
    collider.material.bounciness += 1;
    
    //if you right click the mouse you will decrease
    if (Input.GetButtonDown("Fire2"))
    collider.material.bounciness -= 1;
    }

Uhm, “bounciness” is a float. When you store it in a local variable like you did it’s just a copy of that value. Setting this copy to a different value won’t change “collider.material.bounciness”. You have to assign it to bounciness.

var mat = collider.material;
switch(bounce)
{
case 1: mat.bounciness = 0.1; break;
case 2: mat.bounciness = 0.2; break;
case 3: mat.bounciness = 0.3; break;
case 4: mat.bounciness = 0.4; break;
}