Question by
kitikinjsh · Sep 15, 2015 at 07:21 PM ·
c#collisionplayervisibilityinvisible-object
Invisible objects appear after collision
Hey everyone. I am currently planning on starting one game in Unity, but before that I would like to know: Is it possible to make invisible objects, which would appear after enemy or player collision with it? If it is then could someone give me any advice with it? I know that it may be something different from other requests like making objects invisible after collision, but I need opposite thing. Thanks in advance!
Comment
Best Answer
Answer by MerryAce123 · Sep 28, 2015 at 04:29 PM
Of course, it is possible. You just disable the mesh renderer of an object that you want to make invisible and then you enable it whenever a player or an enemy collides with your object. It could look like this:
void Start() {
gameObject.GetComponent<MeshRenderer>().enabled = false;
}
void OnCollisionEnter(Collision collision) {
gameObject.GetComponent<MeshRenderer>().enabled = true;
}