x


Animated character with simple colliders on joints - rigidbody not finding child colliders.

Short question - Do rigidbodies only use (compound) colliders in their immediate children or should they search down the entire heirachy for colliders?

More detailed info - I have a character model imported from somewhere (3dsmax I think) and I'm moving it around manually and playing animations when needed.

The model is set up like normal I think .

Base    
  -> Pelvis         
    -> Spine
      -> L Thigh
      -> R thigh 

ect.

What I want to do is have this character knock things over in the scene when it moves around. So I attached a kinematic rigidbody to the base element, and I have a script on that that listens for collision events.

Then I add simple sphere or capsule colliders to a few of the joints. Like one on each leg, foot, arm, hand etc.

Now, it seems that a rigidbody will only use the colliders that are in it's immediate children, rather than searching down the heirachy to find all the colliders that exist.

Is that correct? When I put a big box collider on the Pelvis element (directly under the object with the rigidbody and script) it seems to work, but when the colliders only exist much further down the chain (feet etc) I get no collisions.

more ▼

asked May 27 '10 at 04:59 AM

Sam At FPStudios gravatar image

Sam At FPStudios
76 1 3 10

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

2 answers: sort voted first

I posted this on the other forum and mod andeeee posted this response which explains what I was seeing.

A rigidbody incorporates colliders on all its descendants, not just immediate children. However, colliders on moving child objects will not necessarily give the right effect

Child objects that are moved (say by an animation) might be better handled by having their own kinematic rigidbody each. Each limb can have a script that informs the root object of collisions if necessary.

That makes sense now. Since my colliders were being moved by animations, the rigidbody at the root level was not picking up their collisions or triggers.

So, it looks like putting a Kinematic Rigidbody, Collider and simple script on each limb is the way to go.

Just tested that out and it works fine. The script on the limbs just uses SendMessageUpwards to send collision/trigger messages up to the root. Fairly simple.

more ▼

answered May 27 '10 at 11:19 PM

Sam At FPStudios gravatar image

Sam At FPStudios
76 1 3 10

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

OnCollisionEnter() should be called on your parent GameObject that has the rigidbody regardless how deep the collider is in the hierarchy. At least that's how it works for me. You said you have a kinematic rigidbody. Kinematic rigidbodies won't trigger OnCollisionEnter() unless they collide with a dynamic rigidbody. Maybe that's your problem?

more ▼

answered May 27 '10 at 08:57 AM

StephanK gravatar image

StephanK
6k 39 53 93

Thanks for the attemp spree, but I think I've found the answer below. Animations was the problem.

I probably didn't explain it above but my parent kinematic rigidbody is colliding with both dynamic rigidbodies (OnCollisionEnter) and trigger colliders (OnTriggerEnter) and I was listening for both and getting nothing.

May 27 '10 at 11:22 PM Sam At FPStudios
(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:

x1787
x1689
x184
x12

asked: May 27 '10 at 04:59 AM

Seen: 1823 times

Last Updated: May 27 '10 at 04:59 AM