A little prototype I am making for my game, where the player's material should change when colliding with the white object.
gameObject.GetComponent<Renderer>().material = newMaterial;
This code is not working, I even tried to use this code at the start just to check if this works but doesn't.
I have made sure to assign the newMaterial in Unity.
I also tried changing color usinggameObject.GetComponent<Renderer>().material.color = newMaterial.color;
but this also seems to not be having any effect on the player's color.