Hi, I’m trying to grab the material of an object that is overlapping with my trigger and set that to a public variable on the receiving object. I can grab the object it’s self and set a gameobject variable, but I can figure out how to access the material on the other renderer. Here is my code,
//Material Detection System
void OnTriggerEnter(Collider theCollision)
{
if (theCollision.gameObject.tag == "MaterialSwatch")
{
incomingObject = (theCollision.gameObject);
}
}
I’ve tried a few methods below to grab the material on the incoming object, but I can’t get anything to work.
//GetComponent<Renderer>().material.CopyPropertiesFromMaterial(theCollision.gameObject);
//incomingMaterial = theCollision.gameObject.renderer.material;
//incomingMaterial = hit.theCollision.gameObject.renderer.material;