I there any way to duplicate the action of the Edit object > Track to Actuator; so that it can track to a game property and not a object? It would be used to track multiple objects without having to list them all as separate track to actuators in the logic bricks.

blend file demo

  • $\begingroup$ I really hope this question to get answered, I don't want to list all the AI separately :S. $\endgroup$
    – blackhole
    Jul 15, 2014 at 4:52
  • $\begingroup$ The link to your demo is dead. $\endgroup$ Mar 8, 2015 at 17:27
  • $\begingroup$ Almost 5 years later, and the link is still dead. #sad mess $\endgroup$ Dec 31, 2019 at 6:30

1 Answer 1


You can only track one object at any given time, so you'll need to define a set of priorities by which a single target can be selected from a group of valid candidates (objects with the relevant property).

For example, if you wanted to track the closest object with the relevant property, you could do it with this function:

# track.py

def target_prop(cont):
    self = cont.owner
    objects = self.scene.objects

    tracked = [o for o in objects if self["target_prop"] in o]
    tracked.sort(key=lambda o: self.getDistanceTo(o))

    target, *_ = tracked

    act_track, *_ = cont.actuators
    act_track.object = target

    for act in cont.actuators:

Example: track_to_prop.blend

As you can see, you can specify the target property via a property on the tracking object (target_prop in this case). Also, you can set the always sensor to "true level triggering" (aka: "pulse mode"), to constantly re-evaluate the closest target, if that's required.

  • 1
    $\begingroup$ Will you add some info as to what *_ on lines 8 and 10 does? Also will to explain why you need to loop through the actuators to activate them. Thanks $\endgroup$
    – David
    Oct 24, 2014 at 14:42
  • 1
    $\begingroup$ @David That's just iterable unpacking syntax, to get the first element. The variable preceded by the star (the underscore in this case) is a list containing the rest of the elements, with act_track referencing the first. As for the actuators: You don't need to use a loop, as long as you can activate the relevant actuators, but I think a loop makes sense in this case, because I want to activate all that are connected, and that's what cont.actuators represents. $\endgroup$ Oct 24, 2014 at 18:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .