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 Mokhan94 · Sep 23, 2012 at 02:54 AM · collisionphysicsobjectdestroyignore

Collision with a coin

As I am new to unity, I need some help with collision with a coin. The problem is the my character object is a rigid body so when I collide with my coin object my object is affected by its physics. EX. A ball hit on a ledge and rolls in another direction. i need my coin to not affect my object in this way and almost be as invincible but still be destroyed when i collide with it. My collision code is this, function OnCollisionEnter(collision : Collision) {

 if (collision.gameObject.name == "Coin"){
 
 Destroy(collision.gameObject);
 
 
 
 }}

Now this works perfectly fine, its just that i need the physic collision to be ignored. Is there a work around this? Any help will be good for me.

Comment
Add comment · Show 5
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 whydoidoit · Sep 23, 2012 at 03:08 AM 0
Share

You could set the masses appropriate for the objects so that the coin has only an tiny impact on the player - or you could not use a physics simulation on the player/or the coin and just use a kinematic rigidbody you control yourself.

avatar image Brian Stone · Sep 23, 2012 at 03:08 AM 0
Share

Simply make the coin's collider a trigger so it won't interact with other colliders. This is easily done by checking the IsTrigger option in the object's properties in the inspector window. Then trap the trigger collision in the OnTriggerEnter() method.

http://docs.unity3d.com/Documentation/ScriptReference/Collider.OnTriggerEnter.html

avatar image whydoidoit · Sep 23, 2012 at 03:16 AM 0
Share

Which is fine so long as the coin needs to have no physical interaction with anything else I guess.

avatar image Mokhan94 · Sep 23, 2012 at 03:32 AM 0
Share

THAN$$anonymous$$ You, Its works perfectly fine with is trigger on now. Sorry for such a simple question BTW.

avatar image Fattie · Sep 23, 2012 at 06:07 AM 0
Share

it's not a simple question, it raises a critical point a lot of newcomers don't know about. in most cases, it's essential that everything in your game has real world sizes in meters and real world masses in kilogrrams. it's also essential that the "physic material" you use is correct for the object like in the real world. you should got through and do that now!

one of the most famous video game designers in japan, his hobby is guessing the size in cm of objects (I mean in the reel world!) He goes around with a little ruler for this purpose. I make an effort to try to know the mass of things in the real world. In $$anonymous$$G you should know how much the chair you are sitting in weighs, an iPad, a desk, a car, a bus, a small dog, a large dog, a leg, a football, and so on.

So it's a great question!

0 Replies

· Add your reply
  • Sort: 

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

Destroy object if collision is strong enouf 1 Answer

Manually check collision ? 1 Answer

If two of the same objects spawn on top of each other, is it possible to destroy only one? 0 Answers

Physics.IgnoreLayerCollision - Help 2 Answers

Problem with collisions and Destroy(gameObject). 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