Turn an objects mesh renderer on upon collision.

I’ve never accessed mesh renderers from script before so I don’t know if this is how to do it, it doesn’t appear to be working.

using UnityEngine;
using System.Collections;

public class MeshRendererEnabler : MonoBehaviour {

	void OnCollisionEnter(Collision other) {
		if(other.collider.name == "InvisibleBlock")
		{
			renderer.enabled = true;
		}
	}
}

Try this script … attach this c# script to a cube or any game object and add a rigidbody to it and uncheck “use gravity” …create another cube do the same but don’t attach the script and uncheck the mesh renderer and name that cube as “InvisibleBlock”

using UnityEngine;
using System.Collections;

public class MeshRendererEnabler  : MonoBehaviour 
{
	void OnCollisionEnter(Collision other) 
	{
		if(other.collider.name == "InvisibleBlock")
		{
			other.gameObject.GetComponent<MeshRenderer>().enabled = true;
		}
		
	}
}

now make them collide each other