Question by
xpath · Nov 23, 2019 at 01:05 PM ·
particlesystemif-statementsmaterial colormaterial rendererparticle collision
Detect Color in If Statement
Hi guys,
I want to detect changing color. To make the variable true. What am I doing wrong. Thanks for the answer.
Color colorStart = Color.red;
Color colorEnd = Color.green;
Renderer rend;
float duration=10f;
public bool MaterialClean=false;
void Start()
{
rend = GetComponent<Renderer> ();
}
private void OnParticleCollision(GameObject other) {
Debug.Log("touch");
float lerp = Mathf.PingPong(Time.time, duration) / duration;
rend.material.color = Color.Lerp(colorStart, colorEnd,lerp);
}
private void Update() {
if(rend.material.color==colorEnd){
MaterialClean=true;
}
}
}
Comment