# How do I sort out this tracking actuator?

So without explaining everything, the tracking sensor tries to track to an object in a different layer that hasn't been added into the scene.

To fully explain, the problem lies within which object blender tracks. The object, called "Track", is meant to be added in and tracked to. However, the problem is that when the object is added in then I am presuming that the object added in is called "Track.001". This doesn't exist yet so I can't click on it in the tracking actuator. Does anyone have a solution?

• Crawls a property instead of an object, add to the object a property and so on...I think that can be done. Apr 5 '17 at 4:59
• I kind of had that idea, but no idea how exactly to make it use a property. I am assuming you mean kind of like "when so-and-so is added, property set to 1" or something which I know how to do, but how do I make it track to something that has a property?
– user37321
Apr 7 '17 at 18:55

1. Select a plane and create a Navmesh.

2. Add game property to object (the object can be located in another layer and the property can be any type you need).

3. Configure the logic bricks for the tracker object with steering actuator.

4. Finally the script.

tracker.py.

from bge import logic
class Tracker():
def __init__(self, controller):
print('init')
self.objective_list = [obj for obj in logic.getCurrentScene().objects if 'objective' in obj.getPropertyNames()]
self.actuator = controller.actuators['seek']
self.actuator.navmesh = logic.getCurrentScene().objects['Navmesh']
self.actuator.behavior = 3
self.actuator.selfterminated = True
self.tracking_obj = False
self.colSensor = controller.sensors['Collision']

def change_objective(self):
if self.objective_list:
return self.objective_list.pop()
return None

def main(self, controller):
if self.colSensor.positive:
print('HIT..')
self.colSensor.hitObject.endObject()
self.tracking_obj = False
if self.tracking_obj:
print('seeking')
return
print("Getting objective")
self.actuator.target = self.change_objective()
controller.activate(self.actuator)
self.tracking_obj = True

def main(controller):
if not 'init' in controller.owner:
controller.owner['tracker'] = Tracker(controller)
controller.owner['init'] = True
controller.owner['tracker'].main(controller)


Blend File