Question by
sam201412044 · Jun 23, 2018 at 04:28 PM ·
destroycolorcolor change
3 box object change color when 3 blue color will be destory in behind
how to destory the object when the 3box hit in color blue then destory to behind the object if you see the image in left when you hit the box will be change color red,blue and green if you hit 3 same color will be destory to behind. sorry bad english i hope someone understand me :(
void OnCollisionEnter(Collision col)
{
if (col.collider.name == "b1")
{
if (col.collider.GetComponent<MeshRenderer>().material.color == Color.red)
{
col.collider.GetComponent<MeshRenderer>().material.color = Color.blue;
color = true;
}
else if (col.collider.GetComponent<MeshRenderer>().material.color == Color.blue)
{
col.collider.GetComponent<MeshRenderer>().material.color = Color.green;
}
else
{
col.collider.GetComponent<MeshRenderer>().material.color = Color.red;
}
}
if (col.collider.name == "b2")
{
if (col.collider.GetComponent<MeshRenderer>().material.color == Color.red)
{
col.collider.GetComponent<MeshRenderer>().material.color = Color.blue;
}
else if (col.collider.GetComponent<MeshRenderer>().material.color == Color.blue)
{
col.collider.GetComponent<MeshRenderer>().material.color = Color.green;
}
else
{
col.collider.GetComponent<MeshRenderer>().material.color = Color.red;
}
}
if (col.collider.name == "b3")
{
if (col.collider.GetComponent<MeshRenderer>().material.color == Color.red)
{
col.collider.GetComponent<MeshRenderer>().material.color = Color.blue;
color = true;
}
else if (col.collider.GetComponent<MeshRenderer>().material.color == Color.blue)
{
col.collider.GetComponent<MeshRenderer>().material.color = Color.green;
}
else
{
col.collider.GetComponent<MeshRenderer>().material.color = Color.red;
}
}
if (color== true)
{
Destroy(block.gameObject);
}![alt text][1]
[1]: /storage/temp/119410-ss.png
ss.png
(22.4 kB)
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612165325im_/https://answers.unity.com/themes/thub/images/avi.jpg)