How to move a pose (bones) in BGE? Given that I know how to do it outside the BGE

It’s easy enough for a simple bone, which means it’s not parented to (or extruded from) another bone. It also doesn’t have IK. If this is your case:


from bge import logic

cont = logic.getCurrentController()

own = cont.owner
scene = own.scene

armature = scene.objects["YourArmatureHere"]
bone = armature.channels["YourBoneHere"]

up = cont.sensors["up"]

loc = bone.location

if up.positive:
    loc.y += 0.05 #this moves the bone up on the local Y axis
    bone.location = loc

If you do have IK or parenting, look into joint_rotation. You can watch this video if you want a tutorial:

Looks at this script as well:

main_arm.channels['NAME OF THE BONE YOU WANT TO ROTATE'].joint_rotation[ x, y ,z]

(In this thread: https://stackoverflow.com/questions/6961438/change-bones-position-in-a-armature-in-blender-game-engine-using-python)

Or maybe search in the API:
https://docs.blender.org/api/blender_python_api_2_66_4/bge.types.BL_ArmatureChannel.html#bge.types.BL_Arm atureChannel.joint_rotation
(You might need another method, they’re all in there)

I managed to make something like this not a while ago, if you want a can send you a .blend

1 Like