I’d like to use a collision to change the colour of a material on 3 meshes consecutively. So:
Collision occurs and mesh 1 changes colour instantly
Then after 0.5s the second mesh changes colour
Then after 1s the third meshs changes colour
From what I’ve read I need to use a coroutine. I’ve tried scripting from looking at other sources but no luck so far. Inexperienced scripter so prepare to be astounded with my attempt!
Abbreviated below
public material glow;
public float waitTime1 = 30f;
void OnTriggerEnter (Collider col)
{
if (col.collider.tag == "Impulse")
{
impOpticARenderer.renderer.enabled = false;
impOpticBRenderer.renderer.enabled = false;
diencephalonRRenderer.renderer.material = glow;
hemibrainRightRenderer.renderer.material = glow;
StartCoroutine(SequentialRenderers());
}
}
IEnumerator SequentialRenderers()
{
yield return new WaitForSeconds(waitTime1);
cerebellumLeftRenderer.renderer.material = glow;
}