I’m working on a project for a Gundam game that uses homing missles. To lock in on the target the object uses the position of the target versus its own to orient itself towards the object. Pretty simple tracking system, since local movement is localized to forward movements only. (refer to http://solarlune-gameup.blogspot.com/2011/05/python-in-bge-part-8-ai.html )
Anywho, the problem is when the target of the missle is destroyed. To pass the info on which target to track to I had to assign it directly into the object. So when the object dies the rocket is still pursuiting an object that has now been removed from the scene. Since it’s missing from the scene the heat seaker spazzes out and creates some ridiculous lock down error.
How do we account for an object being in the scene…
PsuedoCode
if obj[“lockedOn”] not in the scene:
explode Missle
else:
fly towards obj[“lockedOn”']
You could send a message if you wanted the other homing missiles to know that the enemy is destroyed. you could use this to make them explode or trigger a script to switch target if possible.
the message system worked great for telling the rockets to explode…
there seems to be a problem when the “variable has been freed”
once that happens, there is an error… i handled it for when a rocket is in motion by having the object that it was chasing send it a message…
However, the next homing missile i shoot is still looking for that dead object… i need a way to check if the variable is freed… its not quite the same as being “None”