How to add a sensor to an object using the BGE Python scripting I want to add a sensor to each of several "players" using the bge + python.  Each sensor will need to have its own distance function, because each player has a different range of perception. This is how I add the players to the scene:

for i in range(world_config.initial_population_size):
    pos = Vector((random.uniform(-10,10),
                 random.uniform(-10,10),
                 3))
    p = Player()
    t = own.scene.addObject("Player")        
    t["Player"] = p
    t.worldPosition = pos


Now I would like to do something like.

t.addSensor(Distance=t["Player"].perception())


So that later I can compare which player sees the other in an interaction.
There is no function addSensor in the API search_1  API search_2.

So you can't add a sensor through python. The sensor requires to be added in logic editor for a single object, but you can add an object with a sensor and controller to the current scene.