I’m looking for a script that will change the color of the car when it passes through a hoop in the picture. where and what kind of script am I looking for?
I’m looking for a script that will change the color of the car when it passes through a hoop in the picture. where and what kind of script am I looking for?
the color of the car is most likely defined as a property of the material attached to the car’s renderer.
You need a script that accesses the material and sets the property accordingly.
The name of the property in the shader of the material depends on the shader used.
Thanks for the help, I will try this now!
I use something like this to change an objects colour
public static void ChangeMaterialColour(GameObject obj, Color colour)
{
foreach (SkinnedMeshRenderer renderer in obj.GetComponentsInChildren<SkinnedMeshRenderer>())
{
foreach (Material mat in renderer.materials)
mat.color = colour;
}
foreach (MeshRenderer renderer in obj.GetComponentsInChildren<MeshRenderer>())
{
foreach (Material mat in renderer.materials)
mat.color = colour;
}
}