This is the code that doesn’t work
import bge
def main():
cont = bge.logic.getCurrentController()
own = cont.owner
sensNear = cont.sensors['Near']
sensDelay = cont.sensors['Delay']
actuLook = cont.actuators['LookAt']
actuDamage = cont.actuators['Damager']
if sensNear.positive:
########################################################
if sensNear.hitObjectList[0]['Team'] != own['Team'] and own['Moving'] == False:
actuLook.object = sensNear.hitObjectList[0]
cont.activate(actuLook)
if sensDelay.positive:
cont.activate(actuDamage)
########################################################
else:
cont.deactivate(actuLook)
cont.deactivate(actuDamage)
main()
It works fine except for one problem
What’s wrong is that the object detected, with the index 0, isn’t always on the other team so it won’t attack it.
So what I need is a way to:
See if there is an object not on your team near you
Find which object is not on your team
make that object the object in
actuLook.object