so i am making a tower defense game and need to find a way to make the towers shoot at enemy’s if they are in so many blender units of the tower.
i found that you cant change witch enemy you are shooting at with only logic bricks.
i am rather inexperienced in blender python this is my first script that is more than showmouse.
so i have my robots attaching your base and you can place towers.
on my tower i have a set up like this.
near sensor => python controller => track to actuator
radar sensor => and controller => add object actuator (shoot)
my shooting system works great if there is a robot in front of them they will shoot.
my aiming system works as long as i only have onerobot with the same name every time.
then i can just put in the robots name in track to and replace my python controller with a and controller.
this is the script that i have so far.
cont = GameLogic.getCurrentController() own = cont.owner near = cont.sensors['near'] track = cont.actuators['track'] if near.positive: track.setObject('OBrobot') cont.activate(track) else: cont.deactivate(track)
this is the script i am trying to make
if near is true
get name of near’s hit object
set track to track near’s hit object
keep tracking that object until object is not in near’s range or has died
when that happens find a new target
my current problem is that i cant figure out how to change tracks target object.
i will also need to get near’s hit object and figure out if it is still in range even when there are multiple objects in range
this may be a easy to you but please help