Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 11 Next capture
2021 2022 2023
1 capture
11 Jun 22 - 11 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
1
Question by Okido · Jul 27, 2015 at 04:19 PM · collisionrigidbodylayersragdollmechanim

How can I stop a rigidbody (Ragdoll) character from colliding with the Character Controller capsule?

Hi,

I'm using the Unity 5 Mechanim standard asset for the third person controller ("Ethan"). I want the character to be able to ragdoll, so instead of using a normal model I'm using the ragdoll model (so I can turn the character into a ragdoll just by switching off the animator component).

But (presumably) because of the rigidbodies, the mechanim doesn't work while the player model is inside the capsule collider of the character controller. It jitters and keeps playing through all sort of animationsm or sometimes just crouches. When the ragdoll gets activated it goes flying off over the horizon.

Everything I've looked up to fix this says to put them on different layers to ignore each other. I've done this with the collision matrix as well as code, but it has no affect at all.

if I put the model outside of the char controller capsule it works perfectly (but then I get the offset controls of course).

I'm pretty sure this is a collision problem but I don't know why they won't ignore each other. Any help much appreciated, thanks for reading :)

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
2

Answer by Randcorn · Nov 29, 2017 at 05:55 PM

I got this crouch problem a few weeks ago and got it to work. The problem is the spherecasts in the standard ThidPersonCharacter. They are hitting the ragdoll colliders.

What I did was adding a public LayerMask to the script. Instead of using Physics.AllLayers in the two Physics.SphereCast on line 97 and 115 use this layermask. I set the mask to render all but the "Ignore Raycast" layer. In the inspector, select the Ethan Skeleton and change the layers to Ignore Raycast.

I'm a little late to the party, but maybe it can help someone :)

EDIT:

Adding the code as requested. Add a public Layer Mask.

 public LayerMask raycastLayerMask;

Now on line 97-101 use the layer mask:

 if (Physics.SphereCast(crouchRay, m_Capsule.radius * k_Half, crouchRayLength, raycastLayerMask.value, QueryTriggerInteraction.Ignore))
 {
     m_Crouching = true;
     return;
 }

On row 115-118 use the layer mask again:

 if (Physics.SphereCast(crouchRay, m_Capsule.radius * k_Half, crouchRayLength, raycastLayerMask.value, QueryTriggerInteraction.Ignore))
 {
     m_Crouching = true;
 }

Remove Ignore Raycast(or use any other layer if you prefer). alt text Change the layer of the EthanSkeleton to Ignore Raycast. Press "Yes, change children". alt text


unity01.png (28.3 kB)
unity02.png (9.1 kB)
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 MilkyPancack · Jul 09, 2018 at 03:44 PM 0
Share

Can you add the code for your third person character as i have this exact problem

avatar image Randcorn MilkyPancack · Jul 10, 2018 at 09:48 PM 1
Share

Added the code :) I hope it'll help you

avatar image MilkyPancack Randcorn · Jul 11, 2018 at 05:05 PM 0
Share

Thank you so much for adding the code, it fully works now.

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

23 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

Related Questions

Animator overriding collisions? 0 Answers

Collision between rigid body zombie characters. 1 Answer

Multiple Colliders With Mechanim 1 Answer

Ragdoll with multiple colliders 0 Answers

rigidbody simulation collision check frequency check control?? 0 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