Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by Joebear · Dec 12, 2015 at 03:31 AM · javascripterrordestroybulletdestroy object

Bullet Destroy

I have an error in my Bullet Destroy script: #pragma strict function OnCollisionEnter(coll: Collision){ Destroy(gameObject); } function OnCollisionEnter(coll: Collision){ // do whatever you want to do, then destroy bullet: Destroy(coll.gameObject); }

NOT QUESTION: (( There are multiple things wrong with my asking this question: I have started with C#, and this is in Javascript. It was one of my earlier scripts that I believe was based off of a tutorial. Also, I haven't researched an answer yet, this is my first action. The only reason I'm really asking this question now is because I'm done for the night and won't be able to get back on Unity for the majority of tomorrow, so I figured I would give this time. )) QUESTION: The error is that Unity expects a semicolon where it definitely doesn't belong, which is on line 7, where only a } is. When I add this, a bunch of errors pop up because I'm sure it doesn't belong. What's wrong with my script that makes the Unity engine believe that? Thanks

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by itsharshdeep · Dec 12, 2015 at 07:30 AM

Hello First of all your script contains the OnCollisionEnter Metod 2 times so firstly remove that, Second I copied your code and pasted into my script except the repeat of the method there is no any error present . Following is your code:-

     #pragma strict
     //  function OnCollisionEnter(coll: Collision)
     //  { 
     //  Destroy(gameObject);
     //   } 
        function OnCollisionEnter(coll: Collision)
        { 
                // do whatever you want to do, then destroy bullet:
         Destroy(coll.gameObject);
        }
 

Now it might be the problem that you are not saving your script or you can do like Go in Assets>Open C# project or If you are using the older version of Unity then there is a option like sync ModoDevelop in Assets Menu

If any of the solution not worth you then you can create a c# script and then check the same If this will not work then please let us know.

Thanks

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

40 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

Related Questions

MY effect dont destroy 0 Answers

Destroying Bullet (Impact Effect) 1 Answer

bullet destroy on collison 1 Answer

The bullet never destroyed!!! 2 Answers

Warnings in Java 0 Answers


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