Armature Bone Tracking: influence by sensor?

How do you control Armature bone tracking constraints influence, by the something like distance or radar, or anything you can make sensor from?


you need to use something like a collision box and to use the sensors on this box, then you parent your armature to the box with parent actuator (make sure there is always sensor connected to it)
as far as i know you cannot control the bones themselves in the game engine

Thank you for your post snot_nose

I just read about an update in Blender come 2.57 that allows the bone constraints to work in GE.
You can control the bones themselves in GE. (I just found this out earlier today)

I’m just looking for a way to control the ‘influence’ of the working constraints via sensor or property.

Ok I have an idea…but I’m not sure how to execute it.

I’m thinking of inserting key frames for the ‘influence’ value of the constraints.
Then set up a ‘ipo’ actuator that would be triggered by a sensor.

Problem 1:
I don’t know how to use the ‘key framed’ ‘influence’ in the actuators (I know it’s an F-curve, but how to I tell the actuators which F-curve to use)?

Problem 2:
I have no clue if this can even work.

where did you read it?
because i just tried to use bone constraints and it doesnt look like it’s really working
maybe they were referring to the ‘actuator’ constraint?

Oh, i forgot to mention that you can use edit object actuator and then use track to.
It’s the same like tracking constraint. but again, I don’t believe you can use it on the bones seperatly, only on the whole armature object.
I don’t know what you want to do, but the only thing that works with bones as far as i know is action actuator, so check out, maybe it will be enough for you

I think 2.57 and 2.57b are similar enough for my setup to still work,

just use the arrow keys to move the player
and watch him track the cone.

ah, cool. it’s working!
It seems like it depends on the action actuator to work. if u take out the action actuator it stops working.
so whether you can use this for stopinng the constraint, for example to change to an action where it’s triggered off,
or like you said you can use the F-curve
you can put the track to constraint in frame 50 - 55 with the keyframes on the contraint infuence on 1 and then in frames 100 - 105 for example with the influence going to 0.
so when you want to turn it off you tell him in the f-curve to play between frames 100-105
and when you want to turn it on he plays frames 50-55
you could use the near sensor to trigger this.

if you want i can send you a sample later on to show what i mean

The Action actuator is his ‘idle’ animation.

I’ve disabled it before, and saw that the tracking stops for some odd reason.
My theory, is that the tracking only works because the armature is “active” due to animation…uhh I think.

Anyway, I need to disable the tracking independently from that action actuator. (because in my game, there is always an animation playing. I would prefer a method that keeps the ‘idle’ animation playing)

I would like to see an example involving F-curve, because I have to control the tracking independently from the other actuators.

It would be most helpful to see how to use the F-curve to control it.

There is an option in the Armature actuator to disable a specific constraint (e.g. stop looking at an object). When this is done, then the animation should play through as normal, with all bones animating - with the constraint on, the constraints active will not be affected by the action.
EDIT: Ah, found a tutorial on it. Apparently, you can even control the weight of the constraint on the bone.


Thank you SolarLune, I’ll give this a try and I’ll post the results.

Yes I see that now that it’s controllable.

I think I’ll go with the “Set Weight” solution

Can the value of a float property be used to determine the ‘Weight’ value. Or a ‘near’ sensor.
If so, how would I achieve that? (most likely through script right?)

My goal is to have players ‘gradually’ track objects based on there distance.
-If I’m 2 mi away, you might not look at me,
-If I’m 5 ft away, you would partially turn in my direction.
-If I’m 1 ft from your face, you’ll be staring intensely in my eyes “why are you standing so close to me?”

Ha ha - Yeah, that’s correct. Well, since you only need those three conditions, you could just use logic bricks to control the weight separately, with several logic bricks.

For example, if the near sensor returns > 60, set weight to be 0.1, if a near sensor returns > 30, set the weight to be 0.5, and so on. I heard the near sensor is a performance drain, so it’d be better to do it with scripts since you could just use one (or no) sensors, but if you don’t know Python, doing it with logic bricks is a method. Of course, it wouldn’t be too hard of a script to learn Python for.

Though it’s possible to do it through 3 conditions, I was hoping to minimize amount of logic bricks, by using a script.
(I would also not be limited to 3 conditions with script, it would inherit the exact value of the near sensor. It would just translate into weight.)

I’m thinking of:
#get sensor (near)
-get near value:

get actuator (track to)
-set weight value: equal to (near) value

err something like that, but more like an actual script.

Could you show me an example of how to write in script form?

Ok… Without knowing how the Armature actuator works exactly, here’s an example script.

from bge import logic
cont = logic.getCurrentController() # Get the Python controller running this script
obj = cont.owner # Get the object running this script (the Player, for example)

near = cont.sensors['Near']  # Get the sensor named 'Near', connected to this script
track = cont.actuators['Armature'] # Get the actuator named 'Armature', connected to this script

if near.positive: # If the near sensor returns true
     hitobj = near.hitObject # Get the object that is triggering the near sensor
     dist = hitobj.getDistanceTo(obj) # Get the distance from the hit object to this object
     track.weight = dist / 30.0    # Divide the distance by 30 to get a value from 0 - 1 for how much weight to put on the actuator.
     cont.activate(track)     # Activate the armature actuator

Put that in a text file in Blender, and then plug that into a Python controller. This will activate the Armature actuator when the near sensor is positive, and will set the weight according to the distance away from an object that triggers the Near sensor (attached to the controller).

Wow, I understand it.

Thank so you very much SolarLune, (especially for describing what each line does, this helps me more than you know)

I’ll work this in the example file then upload it.
(in case if anyone needs help with this like I did, they can download the file and use our discussion for reference)

Bone constraints such as “copy location” and “copy rotation” have worked in bge for a while. I use them in my addon to drive bones using the positions and orientations of rigid body objects. Unfortunately there aren’t many tutorials available on this.

It would be great if more constraints were being made available from bge. Do you have a link for the update to 2.57 that you found? I would be interested in reading about this.

A list of constraints on an armature is available through BL_ArmatureObject.constraints. This returns a list of BL_ArmatureConstraint objects.
You can change the settings on the constraints using some basic Python to access the properties of a BL_ArmatureConstraint.
“BL_ArmatureConstraint.enforce” is the value that determines the influence of the constraint. I believe this value has also been used to turn constraints on and off by setting “enforce” to 1 or 0.
“” also looks useful.


Not all armature constraints are supported in the GE.

After reading through the thread again, i found where the other thread was linked about the constraints so my question relating to the source of this is answered.

Support for bone constraints was added along with the iTaSC IK solver. If you’re interested in the details you can find the dev notes here:

Edit: There are some good logic brick techniques posted by SolarLune. I’m going to have to look into the armature actuator some more. :slight_smile:

Thank you for your info FunkyWyrm

I will defiantly look more into this.

I’ve implemented the script, but I’ve made a mistake somewhere and I don’t know how to fix it.
Tracking to (with bone constraints).blend (440 KB)
could someone look this over and see what I did wrong?

Thank you

Oops, I found one of the problems I had.

I forgot to make the Cone an Actor (to make it visible to near sensor)
I fixed it, but I still can’t get the script to work. (I’m so clueless when it comes to script)

If anyone has time to look over my blend, I would very much appreciate any further help you can provide.