This project has moved and is read-only. For the latest updates, please go here.

Attaching Collision Cell to a Body Makes Monster Angry

Topics: Developer Forum
Jan 5, 2011 at 11:04 PM
Edited Jan 5, 2011 at 11:05 PM


I have a large monster which has a number of cells. These cells are used for collision detection only, and so I have set them up as Sensor objects. I have tried attaching them to the monster body via the DistanceJoint as well as the WeldJoint method, and of course have set up the collision categories so that that they do not collide, and also set CollideConnected to false.

However, even though the monster is supposed to stay still, it's as though some strange forces from the cells cause it to get angry and it begins to fidget about on the screen, in escalating amounts!

Any thoughts on what could cause this?



Jan 6, 2011 at 9:29 PM

It's hard to tell. First thing that comes to mind is units not scaled to MKS system maybe?

See: 1.7 Units

Jan 6, 2011 at 11:21 PM

I'm not sure if this is the same problem as I've seen once before, but sometimes too many joints between bodies can make the whole thing oscillate wildly. Make sure you do as Elsch said, but you should also try to up the number of iterations (inside Settings.cs)

Jan 7, 2011 at 6:59 PM

Thanks guys, but no dice. Yes I've double checked that my objects are between .1 and 10 meters. I've also tried multiplying all the iterations in Settings.cs by a factor of 10, but this did not have any effect.

It seems as though the cells attached to the monster are not perfectly "pinned" to it. As in, there is some elasticity between where they connect to it and where they actually are. I would like them to always perfectly coincide with where I've attached them. This might fix it, I don't know... Any thoughts on how to do this?


Jan 7, 2011 at 7:49 PM

Joints are not perfectly rigid. If you need a perfectly rigid joint between two bodies, you should attach multiple fixtures to a single body instead.

Jan 7, 2011 at 7:54 PM

I see, but I need separate bodies so that I can do collision detection for the various cells. Can I use multiple fixtures to rigidly fuse multiple bodies together?

Jan 7, 2011 at 7:59 PM

You can create a single body with multiple fixtures. If you use the OnCollision delegate, you will notice it works on a per fixture basis. You can still detect collisions for each fixture.

Jan 13, 2011 at 11:21 PM

Perhaps I am not fully understanding the relationships between bodies, shapes, and fixtures.

For example, if I was creating a humanoid character with a body and limbs, should I create multiple Body objects for each of his parts? Since each of his parts will be rendered differently and may have different shapes such as being round or rectangular. Or should I rather have one body and attach multiple shapes to it?

For the monster, I need to be able to draw semi transparent images on top of the damage cells. This suggests to me I need to have multiple bodies for the cells... or is this assumption incorrect?


Jan 14, 2011 at 11:12 AM

If you want different parts of your monster to move relatively to each other you should use multiple bodies connected by joints (for something like a ragdoll for example). If your monster is one rigid object with a complex shape/outline made up of different primitives use one body with multiple fixtures attached to it.

As Genbox already said: If it is just a matter of knowing which part got hit how much, just use multiple fixtures on one body and count the hits, individual fixtures received and draw your overlays accordingly on a per fixture basis. You really just need more than one body if you want to move different parts of your monster individually.