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 Van Zeng · Jan 25, 2014 at 10:18 AM · collisionrigidbodycollideroncollisionenter

Why OnCollisionEnter cannot detect collisions between colliders?

I have a transform moving, using Transform.Translate; When I add a rigid body as a component to the game object, my OnCollisionEnter works when the game object hits another collider. But when I add only a collider rather than a rigid body, my OnCollisionEnter isn't called.

Why OnCollisionEnter cannot detect collisions between colliders?

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
1

Answer by Invertex · Jan 25, 2014 at 10:24 AM

Because no collision is technically happening if there is no rigidbody to take force into account. It's just 2 colliders who happen to be occupying the same space, because they have been translated there.

If you absolutely have to use Transform.Translate, then set the Rigidbody to "Is Kinematic". But the way you're supposed to move a rigidbody is with rigidbody.AddForce() or setting the rigidbody.velocity directly.

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 Van Zeng · Jan 25, 2014 at 10:29 AM 0
Share

Thank you I 'm trying your way right away. But according to the manual,

OnCollisionEnter is called when this collider/rigidbody has begun touching another rigidbody/collider.

I thought that should work between 2 colliders. Am I wrong?

avatar image Invertex · Jan 25, 2014 at 10:51 AM 0
Share

Yes, because there needs to be a rigidbody in that equation, for physics calculations to happen. For a physics calculation to happen, something with physics needs to be there, i.e: a rigidbody.

Collision is a physics calculation. If you don't want to go that route, you could use Raycast's ins$$anonymous$$d, or a SphereCast, to check if an object of a certain Tag or Name, or Layer is withing a certain distance of your object. https://docs.unity3d.com/Documentation/ScriptReference/Physics.SphereCast.html

https://docs.unity3d.com/Documentation/ScriptReference/30_search.html?q=raycast

avatar image Owen-Reynolds · Jan 25, 2014 at 06:39 PM 0
Share

No need for metaphysics. One of them needing a rigidbody is just a rule. Look at the last line, 2nd P of the manual: http://docs.unity3d.com/Documentation/ScriptReference/Collider.OnCollisionEnter.html

I always assumed it was just an optimization. If it checked stationary objects, just in case you moved them by hand, physics would run way too slow.

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

20 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

Related Questions

Collision Only being detected on one of the objects involved in the collision - C# 0 Answers

Cannot get collision to do anything 1 Answer

simple onCollision and onTrigger problem 1 Answer

OnCollisionEnter not triggering when two rigidbody collide via Instantiate 1 Answer

Which Object Calls OnCollisionEnter()? 3 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