I make a game with the Blender Game Engine. I would like to make a cube (Enemy) which moves inside a navigation mesh. This cube should follow all the objects with a specific property. The cube also should follow the nearest of this objects in the navmesh. I found this script. But it only work for the "Edit Object" actuator. I need this script work for the "Steering" actuator and the path following. I hope you can help me.
def target_prop(cont): self = cont.owner objects = self.scene.objects test = [o for o in objects if self["Cube"] in o] test.sort(key=lambda o: self.getDistanceTo(o)) target, *_ = test act_track, *_ = cont.actuators act_track.object = target for act in cont.actuators: cont.activate(act)