Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by TheHobbyist · Dec 01, 2019 at 06:02 PM · collisioncollidercolliderscollision detectionrigidbody-collision

Collisions Detection Functions Not Called, Walking Through Walls

Sorry for asking such a common question, but I've gone through so many answers / tutorials, but they all seem slightly different or I'm not understanding how apply those solutions to my problem.

The GameObjects:
1. A wall with box collider that is enabled and is not a trigger. The wall has no rigidbody.
2. An animated character with many rigidbody and collider components so that animation can be turned off and he can ragdoll.

What works:
The animations look great, the conversion to ragdoll looks great, the character's feet stay solid on the floor. Many hours of experimenting and reading to figure all that out.

What doesn't work:
Collisions are not detected with the wall (or other characters). The character walks right through and the character's functions for OnCollisionEnter (or OnTriggerEnter) do not get called.

What I've tried:
I've tried setting the 4 variables below in different combinations it to get collisions working. None seem to help.

What am I not understanding?

 protected void EnableCollisionDetection()
 {
     foreach (Rigidbody rb in gameObject.GetComponentsInChildren<Rigidbody>())
     {
         rb.isKinematic = false;
         rb.detectCollisions = true;
     }
     foreach (Collider c in gameObject.GetComponentsInChildren<Collider>())
     {
         c.enabled = true;
         c.isTrigger = true;
     }
 }
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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by lgarczyn · Dec 02, 2019 at 01:49 AM

IsKinematic should be false unless you check for collisions using a raycast by hand.

IsTrigger should definitely be false if you want to interact with the world.

If you use a dynamic rigidbody, you should use AddForce or .velocity, not MovePosition nor .position.


Also check

  1. Layers

  2. IgnoreCollision calls

  3. MeshColliders with rigidbodies

Comment
Add comment · Show 8 · 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 TheHobbyist · Dec 02, 2019 at 02:13 AM 0
Share

Thanks for the response.

- I have tried is$$anonymous$$inematic false along with isTrigger false.
- I have only the default layer
- I have no mesh colliders, only simple ones
- I don't have any code to IgnoreCollisions, and I double checked the Project Settings to make sure all collision detection types are on.
- The character is moved by the animation, no force or scripted movement involved.
- What's a dynamic rigidbody? Do you mean Collision Detection on the Rigidbody set to Continuous Dynamic? If that is the case, no, I have it set to discrete since I don't have any fast moving objects or needs for precision collision detection.

Any other ideas? $$anonymous$$eep em co$$anonymous$$g! $$anonymous$$uch Obliged!

avatar image lgarczyn TheHobbyist · Dec 02, 2019 at 08:42 PM 0
Share

Animations ignore physics. You can animate the mesh of a rigidbody, you can animate kinematic rigidbodies so that they affect the world but are unaffected, but you cannot animate a rigidbody around and hope they react to walls or ceilings.

Animations don't allow for any freedom of movement, they just set a position. I'm not sure what you were expecting to get.

A dynamic rigidbody is just a non-kinematic rigidbody.

You can try continuous collision detection to increase the chance of the rigidbody 'winning' against the animation, but it has nearly no chance of working.

avatar image TheHobbyist lgarczyn · Dec 02, 2019 at 11:54 PM 0
Share

@ceandros It sounds like you are suggesting that it is not possible for colliders on an animated game object to interact with colliders of other game objects, and that is a very misguided statement.

Show more comments
avatar image
0

Answer by adityalearnstofly · Jul 05, 2020 at 04:01 PM

In my case, I add a character controller on the animated object. I have this zombie character that has animation when get hit. When this zombie dies, I disable the character controller, animator, and iskinematic. When the zombie is still alive the collisions work well because of the character controller. But when it dies, the ragdoll also works well because the character controller, animator and iskinematic is set to disable

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 TheHobbyist · Jul 05, 2020 at 08:24 PM 0
Share

Thanks for the reply. I got stuck on this issue and just called it quits eventually. I'm an experienced developer, but I really struggle with Unity.

Since you use a ragdoll, I assume you have colliders on individual body parts. Are they disabled when the character is animated? Do you have a main capsule collider for when the character is animated? Do you $$anonymous$$d providing a screenshot of your game object hierarchy?

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

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

Related Questions

RigidBody Collisions Detect 0 Answers

Colliders for tunnels 0 Answers

[SOLVED] Colliders aren't working properly. Clipping through ground. 1 Answer

my colliders don't work properly 2 Answers

How i prevent 2 obejcts with kinematic checked in both rigidbodies collide? 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