how to make an object disappear when hit by something unity code example
Example 1: make an object disappear from a c# script unity
public GameObject ObjectToDisappear;
void Start()
{
ObjectToDisappear.GetComponent<Renderer>().enabled = false;
}
Example 2: how to make an object appear and disappear in unity
void Update() {
if (Input.GetMouseButtonDown(0)) {
gameObject.active = true;
}
if (Input.GetMouseButtonDown(1)) {
gameObject.active = false;
}
}