Problem with armature bone rotation via Python

Scripting in Blender with Python, and working on the API

Moderators: jesterKing, stiv

Post Reply
Posts: 0
Joined: Fri Aug 09, 2013 9:04 pm

Problem with armature bone rotation via Python

Post by rbstarbuck »

I'm very new to Blender, so please forgive my incompetence. I need to control an armature using Python so that I can animate a biped model using data from a text file. I've been using this tutorial and some other sources to try and do so, but I can never see any results in the rendered game window.

The test code I have thus far is:

Code: Select all

import GameLogic

arm = bge.logic.getCurrentScene().objects.get('Armature')

arm.channels['Upperleg.L'].rotation_mode = 1


arm.channels['Upperleg.L'].joint_rotation = [.5, .5, .2]

In the console, the values for BL_ArmatureChannel.rotation_euler are changing...

Code: Select all

<Vector <0.0000, 0.0000, 0.0000>>
<Vector <0.5849, 0.4207, 0.3372>>
...but nothing is happening with the model linked to the armature (not visually at least).

On my armature, I have an "Always" sensor attached to a "Python" controller to execute the script. There are no IK constraints on the armature and no other sensors/controllers/actuators. I've added test code to rotate the entire armature--.applyRotation()--which works, but I can't seem to rotate individual joints.

Any help on this matter would be greatly appreciated, my research sponsor is breathing down my neck to get this project done and I can't seem to get this very simple (but necessary) part of it working.

Post Reply