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?

  • $\begingroup$ Crawls a property instead of an object, add to the object a property and so on...I think that can be done. $\endgroup$ Apr 5 '17 at 4:59
  • $\begingroup$ 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? $\endgroup$
    – user37321
    Apr 7 '17 at 18:55

1. Select a plane and create a Navmesh.

Creating Navmesh Navmesh created

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

Add game property to object

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

logic bricks

4. Finally the script.


from bge import logic
class Tracker():
    def __init__(self, controller):
        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:
            self.tracking_obj = False
        if self.tracking_obj:
        print("Getting objective")      
        self.actuator.target = self.change_objective()
        self.tracking_obj = True

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

Blend File


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy