Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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 Satamanster · Jan 24, 2013 at 12:11 PM · gameobjectcrashdestroybasic

Easy collision script not working, don't understand.

So I have this plane which i control around and i want it to destroy itself when it hits the ground, so once i don't want it do destroy imidiatly just for being on the ground i added a sphere collider empty object in front of the nose (i'm thinking addind two on the wings later) and i added this simple script to that:

 #pragma strict
 function OnCollisionEnter(col : Collision)
 {
             col.gameObject.SendMessageUpwards("DestroyPlane", SendMessageOptions.DontRequireReceiver);
             Destroy(gameObject);
 }

I then parented the plane to this tiny object and added this code to the plane control script itself:

 function DestroyPlane() {
 
     Destroy(gameObject);
 }

But for some reason i don't know why the plane doesn't destroy itself when the collider hits anything.... :\

Am i missing something? Cause I can't figure out what how can the script be wrong...

Comment
Add comment · Show 3
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 ryba · Jan 24, 2013 at 12:50 PM 0
Share

No errors ? Did you checked if method DestroyPlane is beeing executed ? Is sphere collider removed ?

avatar image Satamanster · Jan 24, 2013 at 12:53 PM 0
Share

No errors, but that is the problem the method DestroyPlane isn't beeing executed... :(

avatar image DeveshPandey · Jan 24, 2013 at 01:32 PM 0
Share

In this case, lets this OnCollisionEnter() running for the gameObject "go1" and it collide with another gameObject "go2" then DestroyPlane is executed if its available in go2 or its parent.

Verify this and let me know if still not working :)

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Doireth · Jan 24, 2013 at 06:11 PM

From documentation (http://docs.unity3d.com/Documentation/ScriptReference/Collider.OnCollisionEnter.html).

"Note that collision events are only sent if one of the colliders also has a non-kinematic rigidbody attached."

Are you missing a rigidbody? Also, if the sphere collider that should trigger the destruction of the object is too small then the physics engine may miss the collision (can occur if the object "would" have collided between frames).

Comment
Add comment · 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
0

Answer by Satamanster · Jan 25, 2013 at 10:56 AM

That's correct, i was ,missing the rigid body, not it works as it was supposed to... Thank you. ;)

Comment
Add comment · 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

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.

Follow this Question

Answers Answers and Comments

12 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

Related Questions

using Contains(gameObject) to find and destroy a gameObject from a list 2 Answers

Destruct gameobject by call from another script 1 Answer

When all objects with a certain tag has been destroyed, load the next level! 3 Answers

How to destroy GameObject's script(s)? 3 Answers

Destroy object when hit by other object 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