• 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 oinkoinkflapflap · Sep 16, 2010 at 03:57 PM · collisioncolliderwallbullets

making bullets disappear when they collide

when by bullets hit the wall they don't disappear, how can i make them disappear on collision? all answers are appreciated. (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

3 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by AliAzin · Sep 16, 2010 at 04:20 PM

you should write something like this on your bullet prefab:

function OnCollisionEnter(){ Destroy(gameObject);

}

Comment
Add comment · Show 3 · 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 oinkoinkflapflap · Sep 18, 2010 at 07:13 PM 0
Share

Thank u AliAzin ;)

avatar image oinkoinkflapflap · Sep 18, 2010 at 07:19 PM 0
Share

oh it doesn't work :(

avatar image AliAzin · Sep 19, 2010 at 04:07 AM 0
Share

does your bullet have a primitive collider on it?

avatar image
0

Answer by Puddin482 · Dec 20, 2010 at 03:53 AM

If AliAzin's code isn't working, perhaps your bullet object is moving too fast for Unity to pick up the collision, you can try setting the collision detection on your rigidbody to "Continuous Dynamic".

However if you want my two cents as a developer, for bullets or other fast moving projectiles you should use raycasting. But perhaps if you want the bullet to actually travel through the air you can get more complicated with it by raycasting from the old position of your bullet to the new position of your bullet each frame to see if you missed anything during the physics iteration. :) hope this helps!

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 oinkoinkflapflap · Dec 20, 2010 at 05:26 PM 0
Share

thanks thats great, AliAzin's is working fine but if i need to ever use faster moving bullets i know were to look :)

avatar image
0

Answer by XSSA · Jan 10, 2012 at 08:57 AM

function (OnCollisionEnter) { Destroy(gameObject); } This is how you write it. Has problem though it says to put a ";" at the end of the final line. Which results in another error that says: Expressions in statements must only be executed for their side-effects.

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Quickly spinning player glitches through walls 2 Answers

Why is my AI not thinking the collisions fast enough? 1 Answer

Can mesh colliders be used for buildings? 1 Answer

Colliders and GetKey 0 Answers

How to destroy the cube which I selected with the arrow key 2 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