(SOLVED) How do you create accurate collision for a character with a skeleton?

A bit of preface, I’m working on creating a game, and am having troubles getting the collision for my character to work out right.

I’ve tried making the skeleton of my model a character, dynamic and a rigid body and calling it a compound model so that (in theory) the mesh around it is added, but this causes bad results. I’ve tried creating a collision rig by parenting base meshes (arm, leg, etc) to the bones but if I turn on my skeleton’s collision, it breaks the collision by causing my model to fly off the screen, but if I turn off my skeleton’s collision, it turns off the pieces that are parented to the bones as well even if I have them set as rigid bodies. I don’t want to make a cube or a capsule and parant my model to it, because I want the collision to be more accurate. How do I achieve this type of collision?

Blend File:Blend+File.zip (89 KB)

Well you can sense collisions with the body by parenting senor objects to each bone,

But if you are looking for a physical reaction In a armature rig, you will need a walking Ragdoll,
Or some sort of procedural animation deviation system.

I have a updated walking Ragdoll rig in demos ,

Wrectified punching bad demo…, or something like that

I think what you need is here http://wiki.blender.org/index.php/Doc:2.6/Manual/Game_Engine/Physics

scroll down and download the Manual-BGE-Physics-DancingSticks.blend‎ example and see how it uses reinstancePhysicsMesh() to update its collision mesh

Following the example, you should turn off skeleton(armature) collision, the mesh can also have No Collision depenping on what you need.

The example doesn’t really help solve my problem. Neither of the rectangles were actually parented to the skeleton. My issue is trying to create a character that is parented to a skeleton (For reasons of animations) while having the base mesh actually have collisions. If I set the skeleton to “no collision” then all the child objects (including my collision rig) also don’t have collisions no matter what they’re set to. If I set the skeleton to any sort of collision, it collides with my other meshes. And I don’t want to parent the skeleton to one object because I want the collision to be more acurate. I tried the script, and it doesn’t do anything to help remedy this issue.

If there’s a way to have the armature deform the mesh without parenting, that would work too, but I haven’t been able to figure out how to do that (especially since constraints don’t work in BGE.)

@Blu I’ll look at your tutorials and see if I can find the answers there. It seems like collision for characters is a bit wonky, but I’m not too familiar with this sort of thing.

I looked at the demo, and noticed that it too didn’t have a skeleton. Is this type of collision just not possible while having objects parented to a skeleton?

Have you tried enabling the “Ghost” option (under the Physics tab) for either the skeleton or the meshes? Perhaps that will stop all the conflicts between the mesh and the bones. Oh, and I can’t open your .blend file; it says the file is invalid for some reason.

Hi, before we go further with your problem I must first admit that my experience with collision mesh is extremely limited(like 0…) so I’d probably be wrong on many things but according to the links provided, your case is exactly the “more complicated case is the Collision Mesh » Armature » Display Mesh cluster” described by it… so if you follow the setup, you should… be… fine…kinda… (I hope…)

Here are the following things to take note of from the demo

  1. The first rectangle, named “VisualMesh”, is parented to an armature. If you delete its armature, it will stop dancing. The armature itself is parented to “CollisionMesh”. Only the “CollisionMesh” is set to Dynamic physics type while the armature and “VisualMesh” are No Collision physics type.

  2. The second rectangle, named “ShapeKeyedMesh”, albeit an armature is nearby, is NOT parented to anything at all, I’m not sure why the armature is even there in the first place as this rectangle is animated by shape keys alone hence the name “ShapeKeyedMesh”. You can see this clearly by deleting the armature near it and then hit play, the rectangle will still dance. This mesh is set to Dynamic physics type

  3. “Something to note is that the Collision Mesh is merely a plane – that is all it requires for this, since it will be getting the mesh data from viz.” So in case you couldn’t find the “CollisionMesh”, its actually a plane object located near the top of the first rectangle, I totally missed it the first time too if it weren’t highlighted by the manual

So from what I gather the first example should be the one you sought after. I hope this is helpful to you.

very intersesting ,basically also a “normal character” (box->armature->mesh_nocollision) can be converted in a object physic.
and keeping the relations parent -> children overall:cool:
so a character can walk only with the force of animation!

Sorry if I’m not being clear enough on what my issue is:

The example you’re describing is the type of collision that most tutorials and most of blender’s documentation recommends: Real mesh is parented to armature which is parented to collision mesh. The only mesh that collides in the scenario is the collision mesh.

Here’s my problem. In creating a “collision mesh” that the armature is parented to, you lose an incredible amount of precision. Let’s say, for instance, that the collision mesh is a box (which is most common). The box would most likely be above the character’s head. This means that if something collides with the space above the character’s shoulders, it would still count as collision even though it didn’t visually collide with the character’s model. The same applies for a lot of those collisions, because the bounding box is only an outline, so it ignores some things that should have collided with the model and counts collisions that didn’t visually collide with the model.

Even if I were to make the mesh more complex and shrinkwrap it around my character, the mesh is not parented to the armature, so for animations, it won’t move while the character does. This means that if my character is running, the bounding box won’t follow the kicking legs or anything. I could use shape keys to manually animate this new, complex mesh to follow the character, but at that point I’d essentially make the game eat up tons of memory (especially in areas where there’s more than one character) as well as adding a ton of workflow that basically negates the whole reason why I have an armature; to make it easier to animate.

So what I’m asking is if there’s any way to have accurate collisions which follow the character during movement. Or, if that doesn’t work, is there any way I can get my collision rig to follow specific bones in the skeleton within the game engine without parenting? If I could do that, then I could make the collision of my rig and the collision of my skeleton be mutually exclusive, which I think solves my problem.

I’ve tried the ghost option with similar results.

Also, that may be because I’m using a nightly build of blender. I’ll try to fix that.

Real mesh is parented to armature which is parented to collision mesh. The only mesh that collides in the scenario is the collision mesh.

And here is what you’ve been missing, the demo includes a final step to update the collision shape using the “Real mesh” through python script(very important).

I hope this time it is clear to you that demo demonstrate it is not using the shape of of the “collision mesh”, as stated it is only a “plane” object which would have no shape otherwise to collide with anything and had it been used in collision at all the rectangle would fell through the ground until the plane is in contact with the ground, you can see this if you unplug the python script

@@MarcoIT, I’m very inexperience in this so I have no idea how accurate this form of collision can produce(concerning python is involved) but it’d certainly be interesting to see physics that are driven by animations

My walking Ragdoll, walks using animations.

There is a example in resources, non PID Ragdoll,
There is another in game demos, Wrectified melee demo.

When I try to apply the reinstance script and hit play, the program crashes every time. I’m a linux user, how do I check/post that log?

@Koechophe, I’m not sure how blender works in linux but I think the root has something to do with how you apply the script, I remember crashing with mine when I try messing with collision bound or something else but unless you upload your blend for us to test it we won’t know for sure why it had crashed yours?

@@BluePrintRandom, AWESOME! I’ll look it up

Okay, so after a lot of troubleshooting, I discovered that the script will crash if you try to call your collision mesh a “character” collision. It’s fine dynamic too, just vaguely annoying that you can’t use character, because it’s far more convenient. Now I just have to calibrate everything so it runs smooth. So yeah, I have it working, just need to now apply it to my rig instead of my mesh to save on performance.

i sorry but i did not read all of the comments and i dont mess around with animating stuff and all that but could obj.reinstancePhysicsMesh() be what you’re looking for? it recalculates the collision mesh