Homing Missiles To Various Targets
robert.mccarthy
Member Posts: 165
Hi Devs, newbie here.
I am getting into this now, but need a little help. I have managed to get my 'towers' to spawn missiles, and move/travel towards my 'enemies'.
However, ALL the 'missiles' from ALL the 'towers' only navigate to 1 'enemy' until it destroys it, and then it moves to another.
So my question is: How do I get my missiles to only go toward the nearest 'enemy' to itself (so 1 missile will go to one target and another missile to another target).
Thanks and hope to hear from someone soon,
I am getting into this now, but need a little help. I have managed to get my 'towers' to spawn missiles, and move/travel towards my 'enemies'.
However, ALL the 'missiles' from ALL the 'towers' only navigate to 1 'enemy' until it destroys it, and then it moves to another.
So my question is: How do I get my missiles to only go toward the nearest 'enemy' to itself (so 1 missile will go to one target and another missile to another target).
Thanks and hope to hear from someone soon,
Comments
you're probably going to have to use some complicated workarounds to run a loop (explained in this forum somewhere eg http://gamesalad.com/forums/topic.php?id=2807#post-15483, http://gamesalad.com/forums/topic.php?id=1637#post-9036) and use magnitude to get the distance between points: http://gamesalad.com/wiki/interface_reference:expression_editor?s[]=magnitude
you'll probably also need to have multiple variables eg missile1TargetX, missile1TargetY, missile2TargetX, missile2TargetY etc.. so i'd only allow for a maximum number of missiles at one point or you'll have a lot of variables to deal with.
alternatively there is a mathematical topic on how to fake an array of numbers by storing it in 1 big number but i've not tried it: http://gamesalad.com/forums/topic.php?id=3873#post-22598
or you could just try making a simpler game :P