Combining Sensors in python

So I started making a 2d top-down shooter game. In essence there are 3 teams, red, green and blue. Currently, the AI on each unit makes it turn right if an enemy is right, and turn left if an enemy is left, using radar sensors. Also, colliding with a bullet that from an enemy does damage to the unit. The problem is that each unit has 13 radar seniors, including 3 for dealing with walls, and 6 collision sensors for the 3 types of damage. Because of this I can only have about 7 or 8 units per team, as 80-90% of the processing does through the physics engine. Also, I would to, at some point, add more teams (ie. more colors), which would mean each unit could have a couple dozen radar sensors, which is too many.

What I am looking for is a way to combine radar sensors, ie if there is a RedUnit or GreenUnit to the right, turn right, rather than 2 separate sensors. Another option is to make the units look for objects with a value on a property, ie if it is on your team or not. A third option is to make the sensors look for objects with a property but not a material (as each color/team uses a separate material).

Any advice will be lovely

Ok logic
collision with property “Game Item” -------------python block
if target = Whatever-----------------and--------------do Whatever

in python block

import bge

GL = bge.logic

cont = GL.getCurrentController()

own = cont.owner

target = bge.logic.getCurrentController().sensors[“Sensor”].hitObject
own[‘Target’]=target

realistically you have to move a little math in python, to
1 - elaborate better what return from a sensor (easy)
2 - simulate totally sensors that do not exist.(more hard)

this way you can make calculations only when they are needed .

these thing of sensors make clear as SCA is a problem of BGE

Cast a ray towards all the enemies, check if they are in sight, compare the vector towards them with the direction the player/AI is facing, and use that angle to influence turning.

i not know how a ray can manage this sistuation , if a enemy is a bit to right ? the ray not check it.

what i suggest is first of all to use one radar since is probable is the font of the lag .
then to know if the enemy checked is left or right is very easy :

own = curentController()

enemy = radar.hitObject
#then get the vector local :

leftOrRight = own.getVectTo(enemy)[2].x #it return a float

direction = “right”
if leftOrRight < 0 : direction = “left”

print("enemy is to " direction)

target = bge.logic.getCurrentController().sensors[“Sensor”].hitObject

is there a similar function for radar?

I forgot to mention I dont have any real training with python, sorry about the oversight…

A problem i’v been running into is that I don’t want the units running into walls on the map. Is there a way to use a navigation mesh, where the nearest enemy’s name goes into “target object”. So I would need: 1) distance to every enemy, 2) figure out which is closest, 3) throw it’s name into the steering sensor.

I also want to allow the player to choose from various maps, and would rather adjust the unit’s navigation mesh they’re using than make multiple scenes.