Bone Locations

I’m kind of new with blender… and I really need help because this issue is really giving me very hard time …

I want to get the upper limb joint angles (elbow, shoulder) continuously during the game … but I cant even get the location of the bones … I use this code but it always return me zero vector no matter what :[“armature”].pose.bones[“elbow_l”]

can any body help please ?!

Individual bones are not seperate objects so dont have positions.
You should use ;

bone[‘mybone’].head - the position of the base of the bone, relative to parent.
bone[‘mybone’].head_local - the position of the base of the bone, relative to armature (local space)

You probably want the second one. Multiply with the armature’s world matrix to get world space pos.
See also;

.tail - the position of the end of the bone relative to parent
.tail_local - the position of the end of the bone relative to armature
.center - the postion between the two above
.vector - the direction of the bone


To get the _local options, access through;[n]

Thanks very much .That was very helpful
but i still have a problem

Although it gets the correct bone angle at the beginning of the game … it Keeps getting the same angle although the armature moves during the game

do u have any idea how can I overcome this problem!!

Can any one answer me ?!
this is really critical

ont = G.getCurrentController()
own = cont.owner
path = logic.expandPath("//")

controller = bge.logic.getCurrentController()

#act = controller.actuators[“EditObject”]

get object being tracked

obj = act.object

#loc,size,quat = act.getChannel(obj)
cont = G.getCurrentController()
own = cont.owner


def dotproduct(v1, v2):
return sum((a*b) for a, b in zip(v1, v2))

def length(v):
return math.sqrt(dotproduct(v, v))

def angle(v1, v2):
return math.acos(dotproduct(v1, v2) / (length(v1) * length(v2)))

wrist= int(180-angle(v3,v1))


it always return the same angle at the game start even the armature moves during the game