• 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
Question by xXTURDLEXx · Dec 16, 2012 at 12:12 AM · javascriptgameobjectdestroynoob

What is wrong with my script?

When I made this script I get an error: Assets/Scripts/destroyer.js(6,11): BCE0023: No appropriate version of 'UnityEngine.Object.Destroy' for the argument list '(System.Type)' was found.

Here is my script:

 function OnCollisionEnter(theCollision : Collision){
  
  if(theCollision.gameObject.name == "Bullet"){
   
   Destroy (GameObject);
  }
 }
Comment
clunk47

People who like this

1 Show 10
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 clunk47 · Dec 16, 2012 at 01:49 AM 2
Share

Don't use a capital G when referenceing gameObject in Destroy. That's what OrangeLightning is saying. Just change Destroy(GameObject) to Destroy(gameObject);

 function OnCollisionEnter(theCollision : Collision)
 {
     if(theCollision.gameObject.name == "Bullet")
     {
         Destroy (gameObject);
     }
 }
avatar image xXTURDLEXx clunk47 · Dec 16, 2012 at 03:24 AM 0
Share

thanks but My script is not working, not an error but it just not working! i attached it to a cube and want it to dissapear when it touches my bullets, why is this not working?

avatar image GhandiJones clunk47 · Dec 16, 2012 at 03:28 AM 0
Share

Go watch all of these...

http://walkerboystudio.com/html/unity_course_lab_2.html

They're free vid tutorials.

avatar image clunk47 clunk47 · Dec 16, 2012 at 03:28 AM 0
Share

How fast is your bullet moving? Is the bullet a Rigidbody? If so set its collision detection to Continuous Dynamic. Otherwise you may need to look into Unity Raycast

Show more comments
avatar image clunk47 · Dec 16, 2012 at 03:24 AM 0
Share

Thank you for the vote up sir, I've done the same for you.

avatar image xXTURDLEXx · Dec 16, 2012 at 03:26 AM 0
Share
 :)

Thanks!

1 Reply

· Add your reply
  • Sort: 
avatar image
Best Answer

Answer by FLASHDENMARK · Dec 16, 2012 at 12:17 AM

Destroy(gameObject);

Comment
clunk47
AlucardJay

People who like this

2 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 xXTURDLEXx · Dec 16, 2012 at 12:19 AM 0
Share

I still get error:(

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

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

Multiple Cars not working 1 Answer

Is it possible to destroy an object at a specific position? 2 Answers

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

Unity get component help 1 Answer

How to destroy and trigger on enter. 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