x


Dynamically parenting a collider object to a rigidbody object causes collision bug.

Hi, first of all.

I have two GameObject :

  • GameObject A with a Rigidbody and a CapsuleCollider.
  • GameObject B with only a CapsuleCollider.

If I do parenting object B to object A not at runtime, I obtain a fully correct compound object with a collider formed by the two capsules.

But if I try to do parenting at runtime (with the Hierarchy panel or by scripting) the result compound object has an incorrect physical behavior. Indeed, A and B are attached together but B object doesn't collide with the ground (Terrain) and hasn't infuence on the compound object physics.

Note : here the simple hierarchy

  • Object A (rigidbody, collider)
    • Object B (collider)

After somme debug tests, I found that if I do parenting B to A not at runtime, gameObjectB.collider.attachedRigidbody correspond to the rigidbody of the A object. It's ok.

But if I do parenting B to A at runtime, gameObjectB.collider.attachedRigidbody is null. This is abnormal.

Do you ever meet this type of problem and have you an idea to fix it ?

Thanks in advance for your help.

more ▼

asked Apr 28 '10 at 02:18 PM

XeNoTimE gravatar image

XeNoTimE
73 2 2 7

report it as a bugg to UT please. thank you!

Apr 28 '10 at 06:17 PM Ashkan_gc
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

Add the rigidbody component after you do the parenting.

more ▼

answered Apr 28 '10 at 03:51 PM

Eric5h5 gravatar image

Eric5h5
80.3k 42 132 521

Thank you very much. It's logical and works perfectly.

Apr 28 '10 at 04:31 PM XeNoTimE
(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:

x1797
x1705
x426
x374
x149

asked: Apr 28 '10 at 02:18 PM

Seen: 1798 times

Last Updated: Apr 28 '10 at 02:18 PM