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 Loff · Apr 27, 2014 at 01:23 PM · 2dcollisiontrigger

Collision vs trigger

Hello everyone.

Trying to learn Collision, but I'm stuck at this 2D collision.

Why is trigger working but not OnCollisionEnter2D ? This is only if I have actived "Is Trigger"

Both game objects have a collision box.

  function OnCollisionEnter2D (hit:Collision2D){
         if(hit.collider.tag == "Ground"){
                 Destroy (gameObject);
         }
 }
 /*
 function OnTriggerEnter(hit:Collider){
         if(hit.tag != "Ground"){
                 Destroy (gameObject);
         }
 } */
Comment
Add comment · Show 8
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 Burla · Apr 27, 2014 at 02:41 PM 0
Share

Does at least one of the colliding GameObjects have a Rigidbody?

avatar image Loff · Apr 27, 2014 at 02:52 PM 0
Share

I tried to add it earlier just for a test, and it says it already has box collider. I'm testing this on the ground and the player at this moment, they are working pretty well together (collision - $$anonymous$$ovement etc). Just not able to use the function somehow.

avatar image MadJohny · Apr 27, 2014 at 02:54 PM 0
Share

Do you have a 2d collider? weird that in a 2d game the OnTriggerEnter works and OnCollisionEnter2D doesn't... it seems like you are using 3d colliders from your description

avatar image Loff · Apr 27, 2014 at 03:02 PM 0
Share

They are 3d colliders, 3D box and Capsule. Is that a issue?

avatar image MadJohny · Apr 27, 2014 at 03:09 PM 0
Share

ofc it is, you should use box 2d collider and for the capsule, 2 2d sphere colliders with a box collider in the middle, if it's for a character, you use only a sphere collider for the bottom and a box collider for the body, all 2d colliders though!

Show more comments

1 Reply

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

Answer by MadJohny · Apr 27, 2014 at 03:26 PM

if you are want it to use that way you can, you will have to program the game like if it was a 3d game though, which isn't that bad. But to be honest, I think the 2d toolset is more powerful and optimized than the original one (3d). I recommend you taking a look at the tutorials on the unity website, they have a tutorial series dedicated to the 2d toolset I think. I would convert it to 2d since it's more powerful and seems to be better overall, but if you want to keep it the way it is atm, it's your choiche.

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

22 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

Related Questions

Trouble Descaling 2D object 1 Answer

Find the highest point of a stack of gameobjects 2 Answers

Why my triggers don't collide? 2D 0 Answers

Collision with renderer.enabled? 0 Answers

Check if a Collider2D is hit by a Trigger Collider2D 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