So I’m making a script to change the color of two parts of my player ( a 3 piece rocket ship). The body and front need to change color while the engine stays black. It needs to change the colors when it enters an object but I’m having problems calling the child and I’m not sure if they will change color.
public class Collection : MonoBehaviour
{
public Color White;
public Color Green;
public Color Red;
public Transform tForm;
public GameObject gObject;
private gObject.tForm.Find.("Body") = body;
void OnTriggerEnter(Collider other)
{
//green
if (other.gameObject.tag == "GreenCube")
{
other.gameObject.SetActive(false);
//gObject.tForm.Find("Body");
//Body.material.SetColor("_Color", Green);
}
//red
if (other.gameObject.tag == "RedCube")
{
other.gameObject.SetActive(false);
}
}
}
I’ve only started on the green, I’ll do the Red once the answer is given.