Multiple Object AI

“Sweep”

“Component AI”

swivel


import bge




def main():


    cont = bge.logic.getCurrentController()
    own = cont.owner


    own.worldOrientation=own.parent.worldOrientation
    own.applyRotation((0,0,own['Animus']*.05),1)


main()




Set target


import bge




def main():


    cont = bge.logic.getCurrentController()
    own = cont.owner


    sens = cont.sensors['Ray']
    if 'init' not in own:
        own['init']=bge.logic.getCurrentScene().objects['NavBase']
    else:


        if sens.positive:
            own['Target']=sens.hitObject
            own['init']['Target']=sens.hitObject
            own['init']['TargetName']=sens.hitObject.name


main()



Navigate


import bge




def main():


    cont = bge.logic.getCurrentController()
    own = cont.owner


    sens = cont.sensors['Property']
    actu = cont.actuators['Steering']


    if sens.positive:
        if own['Target'].invalid==False:
            actu.target=own['Target']
            cont.activate(actu)
    else:
        cont.deactivate(actu)


main()




Empty target


import bge




def main():


    cont = bge.logic.getCurrentController()
    own = cont.owner


    sens = cont.sensors['Property15']
    if 'init' not in own:
        own['init']=bge.logic.getCurrentScene().objects['NavBase']
    else:


        if sens.positive:
            own['Target']="Empty"
            own['init']['Target']="Empty"
            own['init']['TargetName']="Empty"
            own['Reset']=0


main()




Attachments

ComponentAIRestart.blend (487 KB)

I made ai bots that went around the player shooting at him.This seems like a similar idea.I prefer that they switch directions
randomly.