Homing Script


I’m newish to the game engine but i’m a long time blender user.
i was searching for a way to track multible objects

example. many targets on spawned, player spawns 1 or more projectiles and they track to the nearest target, its removed and the projectiles that don’t hit it update and track next nearest target.

i can set up a single projectile tracking a single target but i need python ( of which i have limited/no knowledge) to up dated which target to track based on how close they are and track new targets when they are spawned.

could tracking to a property work in python?

i found this but i don’t know how to use it. the example .zip link is dead

any help appreciated.


Is possible ! Download my script’s (i use in “SW2-Laber Tanks”)


i had a version of your script already and it gave me errors, this one works.

one problem still though.

i spawn the object that needs to be tracked to. it tracks it. i spawn another and
your script tracks the newest one spawned. is there a way to track the nearest to the “turret” object?

Well i figured out a way to use your script that will suit my project,

from ‘turret’
[ray: prop ‘enemy’]------[ ]--------------[add object ‘target’]

it’ll mean fired ‘missiles’ will track whatever ‘enemy’ is in front of the player.

a nearest target option would still be useful.

Thanks for your help.


Script of distance(for sensor):

Thanks you’ve been a great help.

sorry to be a pain but how could i use the calc distance script on multible spawned abjects to work out the closest to the player?

i presume from what i’ve read in other posts i need a piece of code to get the distance property from all the spawned objects and compare them the get the lowest value.
i don’t know any python code though.

i’ve been reading the blender game python basics tuts but i’m still rather confused.
its something i’ll have to sit dowwn and learn some day but i’ve alot of stuff going on in college at the moment.

i didn’t mention, i’m learning the blender game engine for a project for my final year in the National College of Art and Design Ireland. i’m studying Fine Art Media and blender has been used in many of my previous projects.