This question was
closed Nov 21, 2016 at 02:25 AM by
Bobshortsnicker for the following reason:
The question is answered, right answer was accepted
Question by
Bobshortsnicker · Nov 21, 2016 at 01:20 AM ·
collision
When two different 3d objects touch each other I want one of them to turn green, how do I do this?
here is the code for the first object. This object is my character that I can move.
void tagstuff()
{
gameObject.tag = "guy";
}
here is the code for the second object, this is the object I want to turn green when object one touches it.
void OnCollisionStay(Collision collision)
{
if (collision.collider.tag == "guy")
{
collision.gameObject.GetComponent<Renderer>().material.color = Color.green;
}
}
Comment
You can't set tags at runtime. This is probably your problem.