• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by kadenatmore · Aug 21, 2016 at 09:27 PM · destroycollision detection

How to remove multiple objects on touch

So I am making a game where you start in a plan, grab your weapons and slide down to the ground, for no reason really I found a glitch that allows my player to slide down on a steep surface, and I wanted to find a way to incorporate that into my game. But my question is, how can I make it so there is a collider at the bottom of the slide, then when you slide down and hit it, it removes the collider, the slide and the plane, does anyone have any ideas, and if you could help me with something else, I need to know how to trigger a script that is attached to 4 spawner objects, also when you hit the collider, so the enemies don't start spawning while your still in the plane. Thanks in advance!!

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Firedan1176 · Aug 22, 2016 at 12:21 AM 0
Share

I'm kind of curious, what do you need to destroy the collider for? Are you wanting it to trigger something?

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by tiggy02 · Aug 22, 2016 at 05:08 AM

Put this script inside the "player" object (the one that falls down the slide.)

 public GameObject slide;

 void OnCollisionEnter(Collision col)
 {
     if (col.gameObject.name == "plane")
     {
         Destroy(slide);
         Destroy(col);
     }
 }

This will work assuming you dragged the slide object to the proper spot in the players inspector and the plane is called "plane"

For your second question make a really big collider and set it to IsTrigger true (check the box)

 public float timeYouWantInBetweenEachEnemy;

 void OnCollisionEnter(Collision col)
 {
     if (col.gameObject.name == "reallyBigColliderIToldYouToMake")
     {
         InvokeRepeating("SpawnEnemys", timeYouWantInBetweenEachEnemy, timeYouWantInBetweenEachEnemy);
     }
 }

 void OnCollisionExit(Collision col)
 {
     if (col.gameObject.name == "reallyBigColliderIToldYouToMake")
     {
         CancelInvoke("SpawnEnemys");
     }
 }

 void SpawnEnemys()
 {
     //Instantiate the enemys here.
 }

Now set the public float to whatever you want and then this will work assuming the you called the collider reallyBigColliderIToldYouToMake.

P.S. This is untested but should work properly, comment if you need any more help.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image tiggy02 · Aug 22, 2016 at 12:25 AM 0
Share

You don't need to make the spawner locations spawn the "enemys" you can just Instantiate (Clone) the enemys at their locations which is much easier.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

56 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Help with collisions and destroy please 1 Answer

Why are the objects (they are cows) randomly disappearing? 2 Answers

OnTriggerEnter2D & OnCollisionEnter2D Not Responding 1 Answer

Player colliding with object then destroying/killing Player 2 Answers

,Destroy Gameobject on collison not doing anything! 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges