Home Coding, Scripting, Shaders

unity material change after collision not working

Offline / Send Message
Pinned
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 using
gameObject.GetComponent<Renderer>().material.color = newMaterial.color;

but this also seems to not be having any effect on the player's color.
Sign In or Register to comment.