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 /
This question was closed Jul 23, 2017 at 02:12 AM by tonycoculuzzi for the following reason:

Problem is not reproducible or outdated

avatar image
1
Question by tonycoculuzzi · Nov 21, 2011 at 03:05 AM · collisionrigidbodycollideroncollisionenter

Which Object Calls OnCollisionEnter()?

When a collision happens, does the object with the rigidbody have to call the OnCollisionEnter, or can either? I'm having a problem where the OnCollisionEnter object is on an object without a rigidbody, and will not call when hitting the Player, which has a rigidbody.

Both objects have box colliders, and neither are marked as triggers.

Edit: This issue no longer happens in newer versions of Unity.

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

  • Sort: 
avatar image
3
Best Answer

Answer by Eric5h5 · Nov 21, 2011 at 05:34 AM

OnCollisionEnter is called on any object involved in a Collision event.

Comment
Add comment · Show 12 · 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 tonycoculuzzi · Nov 21, 2011 at 06:40 AM 0
Share

I thought so. However, the function is only called when I have a rigidbody on the object as well as the player. The rigidbody on the player is not marked as $$anonymous$$inematic, yet it doesn't call the function. Any idea on why this may be happening?

avatar image Eric5h5 · Nov 21, 2011 at 07:12 AM 0
Share

How are you deter$$anonymous$$ing that? If I have this script:

 function OnCollisionEnter (other : Collision) {
     Debug.Log (other.gameObject.name);
 }

and I put it on two objects, a cube (collider only) and a sphere (rigidbody + collider), then have the sphere drop onto the cube, in the output is two lines, "Cube" and "Sphere".

avatar image tonycoculuzzi · Nov 22, 2011 at 12:35 AM 0
Share

That's the odd thing, it isn't being called on either, unless both objects have a rigidbody. Does the object with the rigidbody need to be the object that moves into the collision? And I've tested it with on one object or the other, and the collision is still not detected.

avatar image Eric5h5 · Nov 22, 2011 at 12:56 AM 0
Share

If objects are static, they should not have rigidbodies. If objects are moving, they should. ($$anonymous$$anually moving objects with colliders but no rigidbodies causes the physics engine to have to recompute collision trees, which is a drain on CPU.) However, a rigidbody will collide just fine with an object that has no rigidbody, and both objects get collision messages, as I described in my previous comment.

avatar image tonycoculuzzi · Nov 22, 2011 at 01:33 AM 0
Share

Both objects move, only the player moves form side to side while objects move toward them. Something I just discovered, if the object starts close enough to the player that it lags into the player when pressing Play in the editor, the event is called.

Show more comments
avatar image
0

Answer by DaveA · Nov 21, 2011 at 03:57 AM

If the OnCollisionEnter function is in a script on the Player, it will fire in that script with the 'collider' parameter indicating the other object. You could try putting this function on the other object and see if both fire, indicating each other.

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
avatar image
0

Answer by Jeff-Kesselman · Nov 16, 2014 at 05:50 PM

The stock Unity player controllers have their own private physics and collision implementations. As mentioned in comments above, they have their own, different callbacks defined.

This is a pain in the butt. I pretty much always build my own player objects instead unless its for a very quick test of something else.

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

Follow this Question

Answers Answers and Comments

7 People are following this question.

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

Why OnCollisionEnter cannot detect collisions between colliders? 1 Answer

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


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