Search Unity

  1. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  2. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  3. Want more efficiency in your development work? Sign up to receive weekly tech and creative know-how from Unity experts.
    Dismiss Notice
  4. Participate with students all over the world and build projects to teach people. Join now!
    Dismiss Notice
  5. Build games and experiences that can load instantly and without install. Explore the Project Tiny Preview today!
    Dismiss Notice
  6. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  7. 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:
    413
    "Disappears" as in the object gets destroyed, disabled, or turns invisible?
     
  3. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    3,939
    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).