Search Unity

  1. Get all the Unite Berlin 2018 news on the blog.
    Dismiss Notice
  2. Unity 2018.2 has arrived! Read about it here.
    Dismiss Notice
  3. Improve your Unity skills with a certified instructor in a private, interactive classroom. Learn more.
    Dismiss Notice
  4. ARCore is out of developer preview! Read about it here.
    Dismiss Notice
  5. Magic Leap’s Lumin SDK Technical Preview for Unity lets you get started creating content for Magic Leap One™. Find more information on our blog!
    Dismiss Notice
  6. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

disapering script

Discussion in 'Getting Started' started by vindawg2009, Jun 30, 2018.

  1. vindawg2009

    vindawg2009

    Joined:
    Jun 30, 2018
    Posts:
    1
    how do you make a script that when an object touches another object it dissapears? thanks in advace
     
  2. Cucci_A

    Cucci_A

    Joined:
    Jan 23, 2018
    Posts:
    205
    "Disappears" as in the object gets destroyed, disabled, or turns invisible?
     
  3. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    2,734
    Take a look at the physics system and specifically OnCollisionEnter and OnTriggerEnter methods. One of those will be what you'd normally use to detect when an object "touches" another object.

    After that, as Cucci_A asked, you need to decide what you mean by "disappears". You can destroy the object with a Destroy call, you can disable the object, you could disable its mesh renderer, you could swap or modify its material so it becomes transparent, and I'm sure there are more options. How you choose to make it transparent would depend on what you want to do with the object in the future, or if you want to have this be part of some disappearing effect (like having it fade out instead of instantly vanish).