I want to read the armature space location and rotation of an armature bone using python.
I’ve managed to get a reference to the bone using own.channels[‘bone’] but then I want to get useable data about the bone’s rotation and location. When I say useable, it means I want to be able to transfer that data to worldLocation and worldOrientation, or to be able to ray cast from that location.
Anyone have any ideas?
OK, I solved it myself.
It seems that .toEuler became .to_euler and no one told me
cont = bge.logic.getCurrentController() own = cont.owner bne = own.channels['head'] loc = bne.pose_tail pose = bne.pose_matrix head = [ob for ob in own.children if ob.get("head",False) ==True] head.localPosition = loc new_pose = pose.to_euler() head.localOrientation = new_pose
This way you can do some of the following cool things:
Have a hat that can fall off when the character gets shot.
Have arrows that stick in a monster and move acurately in line with its animations.
have parts of a player or monster catch on fire, and the fire follows the character’s movements.
Have a character pick something up and put it down such as a book, lamp or other item.