Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

how to make dissapear an object in unity

public class Player : MonoBehaviour
{
    //Set this game object by dragging on UI
    public GameObject body;

    private void OnCollisionEnter2D(Collision2D other) {
      if(body != null){
        body.GetComponent<Renderer>().enabled = false;
        Destroy(body);
      }
    }
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #dissapear #object #unity
ADD COMMENT
Topic
Name
2+8 =