How to spawn a mesh with armature ? (armature gets disconnected from mesh)


I have a Mesh, an Armature and an Empty.

I set parent of Mesh to Armature (with automatic weights).

Then I set parent of Armature to Empty, so that I can move the Empty and the whole armature/mesh thing moves.

This works fine, Ok.

The problem arises when I addObject( Empty )

The idea is to addObject(Empty) and let it automatically create everything,
because from what I have seen when you addObject an object, it also creates its children.

Now, what I want to do works, except that the mesh gets disconnected from the armature. The Empty is created,
the mesh is also created (you can see it) and the armature is created (because I reference it and even turn some
bones with code), but the mesh does not animate.

Its as if everything works except the armature gets disconnected from the mesh.

How can I fix this ?

Agent =

1 physics hitBox
1 armature
1 skin

Skin is parented to armature, and contains a armature modifier [ no collision physics]
Armature parents to hitBox [ no collision physics]
hitbox is where you apply forces etc and move the agent, actions should happen ‘inside the hitbox’.

IE the armature should not jump, the armature should ‘jump while holding still’ and the agent hitbox should apply forces to jump.

to add a agent simply spawn a copy of hitBox -> hierarchy brings in the rest.

you can do

hitBox = own.scene.addObject('HitBox',own,0)

for child in hitBox.childrenRecursive:
   if 'SkinTag' in child:


I add the property ‘SkinTag’ so it’s easy to look up to replace mesh, or change color etc.

This is what I am doing.

The problem is that the skin does not pose. It gets brought in, but does not pose.

Check the attached file that demonstrates my problem.

Go to layer 3, press play. The empty will add the hitbox (from layer 1), which will bring in the others.

But shouldn’t the doll have his arm up ? Like the original in layer 1 ?

The blue bracer shows that the armature has been brought in posed (with arm up). The blue bracer works, follows the armature Ok.
The skin does not work, it does not follow the armature.

Attachments (127 KB)

This has nothing to do with adding objects. Your armature has no logic to do anything.

Ok here is another example : (84.5 KB)

The tentacle at leayer 1 bends (just press play)

Now go to layer 3 and press play. The tentacle does not bend.

Notice how the blue cylinder (which is tied to a single bone) moves, , which means the armature is animating.

Why does not the tentacle move ?

It seems if I add an Armature -> Play actuator, it works. Just create a dummy animation to put in the actuator box, and play it from frame 0 to frame 0.
Then the CopyRotation contraint from the little cube is suddenly applied. :smiley: WTF !!! :smiley:

Since this a lucky result and am developing a rather large project here, perhaps someone could point me to some documentation, or explain what’s going on ? This is a crucial part of my next game and I need to understand what I am doing.

There is not even an action.
What did you expect? You told the armature to do nothing. It does exactly that … nothing.

To see an animation you either play an action (action actuator) or you do some armature stuff like IK (armature actuator).

Nope, there is another way without actuators =

You bind the bone with bone constraint --> Copy Rotation to some object (e.g. a simple cube) and then with python rotate the cube =

mat = mathutils.Matrix.Rotation( math.radians(someAngleToRotateTheJoint), 3, 'Y')
 cube.localOrientation = mat

Et voila! Just like that, you can animate cubes instead of bones ! :slight_smile: I have tried it, it works.
You just need to call update( ) on the armature to see the changes. No logic bricks anywhere.

The thing is that when you spawn the whole thing, it does not work anymore. It needs actuators to fix.

I can not understand what is the difference between the spawned instance version and the “original” version.
Because they obviously behave differently.

It is not a so very important question for me anymore, because I will use the actuators from now on per your
suggestion. But if you feel like discussing why the spawned version is different, I am all ears.

Thanks Monster!


I’m not into this topic.

I play actions on armatures. I wasn’t in the situation to run an armature without action (beside of some experiments).

I literally just spawn the armature into the current state and the object spawns with it?
It seems you can spawn any object with children and expect them all to spawn with the parent.
But the children you can’t expect the parent to be with it when you spawn them.

You get the children but no the parents.