x


Collisions with Rigidbodies with Kinematics

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?

more ▼

asked Sep 17, 2011 at 08:41 PM

Ves gravatar image

Ves
48 32 24 29

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

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.

more ▼

answered Sep 18, 2011 at 12:09 AM

Bunny83 gravatar image

Bunny83
85.4k 31 169 433

(comments are locked)
10|3000 characters needed characters left

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

Enjoy it

more ▼

answered Nov 21, 2013 at 04:24 PM

vackup gravatar image

vackup
1

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

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

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x4367
x3249
x137

asked: Sep 17, 2011 at 08:41 PM

Seen: 10493 times

Last Updated: Nov 21, 2013 at 04:24 PM