I can't seem to find a specific answer for this. Mainly, I have an enemy rigidbody in my game who, when hit by an attack of some large value, goes ragdoll (isKinematic = false). However, when he is chasing the Player with isKinematic = true, he phases through terrain and such.
Is there an elegant way of having an enemy be allowed to go into ragdoll and still collide with the environment?
Answer by Bunny83
Sep 18, 2011 at 12:09 AM
Actually the only two components that can detect collisions are: the CharacterController and a non-kinematic RigidBody without any exceptions (afaik). However the CharacterController uses it's own detection method and is not really part of the physics system.
The only difference between a simple GameObject with a collider and one with a kinematic Rigidbody attached is that the kinematic Rigidbody can wake up other non-kinematic Rigidbodies. Non-kinematic Rigidbodies fall asleep after a few seconds. They can only detect collisions when they are awake. If you move a GameObject with a sleeping Rigidbody it will wake up automatically, no matter what method of movement you're using (transform.position, AddForce, MovePosition).
The only use of a kinematic Rigidbody is that when you move it into a sleeping Rigidbody it will wake up and would perform the collision check. Keep in mind that the collision messages are sent to both objects but only a non-kinematic Rigidbody can produce them.
I'm not sure how your ragdoll-setup looks like, usually you have multiple body parts that are connected with joints. To move the enemy while he's alive you should use either a CharacterController, or a non kinematic Rigidbody. You should remove it when you turn it into a ragdoll.
If you use a Rigidbody you can set freezeRotation to true so the Rigidbody is not rotated by the physics system but you're still able to rotate the object via script. You can also use Rigidbody.constraints to prevent the rotation and / or position change caused by the physics system.
Answer by vackup
Nov 21, 2013 at 04:24 PM
HI Ves, I had the same problem and here you have how I solved it http://vackup.blogspot.com.ar/2013/11/unity-ragdoll-and-collisions-with.html
Basically It was creating the ragdoll at runtime with a script.
Visit the blog post and you have the detailed intructions and some useful links
Answer by wonderkid
Nov 25, 2015 at 03:09 PM
Using 2 colliders and checking one of them "isTrigger" solved my problem
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
The best place to ask and answer questions about development with Unity.
To help users navigate the site we have posted a site navigation guide.
If you are a new user, check out our FAQ for more information.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
Answers and Comments
6 People are following this question.
Child Rigid Body collision problem
Having a kinematic rigidbody detect collision with a collider without a rigidbody
Make isKinematic false when touching a Collider?
Rigidbody with Physics or Kinematic Rigidbody
seeking collision scenario solution : falling anvil vs. player