I have different materials with different color for each gameobject. manage to change all materials color but didn’t manage to revert them back to their original state. the objects revert back to full black color. cant find the cause of this. here’s an example script:
private Color originalColor;
void Start()
{
foreach(Material mat in this.gameObject.GetComponent<Renderer>().materials)
{
mat.color = originalColor;
}
}
void OnCollisionEnter(Collision other)
{
foreach(Material mat in this.gameObject.GetComponent<Renderer>().materials)
{
mat.color = color.grey;
}
}
void OnCollisionExit(Collision other)
{
foreach(Material mat in this.gameObject.GetComponent<Renderer>().materials)
{
mat.color = originalColor;
}
}
@Linkthehylian04 His intentions aren't bad. I think that what he's getting at is that you have to try to think about the problem and try to solve it before you ask the question instead of saying something like "help me write this script." In my answer I was trying to point you in the right direction. Ask, what do you want the enemy to do then try to figure out a way to make it do that.
– Rickyinjp