I am trying to simply move a bone that has been parented to a mesh in Blender 2.69. I want to do this in real-time - while the BGE is running. I linked an Always logic block to the python code seen below. Can anyone point out to me why this code does not move the ‘Bone’?
import bpyimport bge
import GameLogic as GL
#"bge.types.BL_ArmatureChannel(PyObjectPlus)" in the documentation means that BL_ArmatureChannel is a subclass of PyObjectPlus.
import mathutils
# The owner is an armature, so 'alien' will be a BL_ArmatureObject instead of KX_GameObject
cont1 = bge.logic.getCurrentController() #makes: SCA_PythonController
cubeBone=cont1.owner #makes: BL_ArmatureObject
#get the scene for the mouse and other things
scene=bge.logic.getCurrentScene()
#get a keyboard
keyboard = bge.logic.keyboard
def main1():
if bge.logic.KX_INPUT_ACTIVE == keyboard.events[bge.events.DOWNARROWKEY]:
#cubeBone.channels['Bone'].location = mathutils.Vector([3, 5, 8])
print (cubeBone.channels) #prints the channes available
print(cubeBone.channels['Bone'].rotation_euler)
print(cubeBone.channels['Bone'].joint_rotation)
#class: bge.types.KX_GameObject(SCA_IObject)
#cubeBone.channels('Bone').localPosition.z +=0.1
#cubeBone.channels('Bone').rotation_mode'XYZ'
#cubeBone.channels('Bone').rotation_euler([5,5,5])
#cubeBone.channels('Bone').joint_rotation([0.0,0.0,0.1], True)
cubeBone.channels['Bone'].rotation_mode = GL.ROT_MODE_XYZ
cubeBone.channels['Bone'].rotation_euler=[25,25,25] #BL_ArmatureChannel.rotation_euler
print("bone moved")
cubeBone.update()
print(cubeBone.channels['Bone'].rotation_euler)
############# end of main ###############################
main1()
cubeBone.update()
The Console prints out the new vectors that are changed, but the animation does not move. I found this post: (http://blender.stackexchange.com/questions/2256/controlling-armature-through-python?rq=1) but there are mixed answers and they are not very helpful for noobs. Thanks guys