How To Target Any Nearby Enemy
Posted: Sat Mar 16, 2013 8:37 pm
Hello everyone,
I have been slacking on game developing for a while and I'm ready to get back into it for a little bit.
So, what I need help doing is targeting any nearby enemy with a crescent (a projectile weapon). I want to have an upgrade for the crescent that starts constantly moving towards an enemy (like heat seeking missiles or whatever). Usually the crescent just goes in one direction only changing direction by colliding with something. But I want this to kind of pull towards a nearby enemy when the upgrade is active.
I know that for the actual following I would just have to have directional velocity and an angle in the draw actor of the crescent with some if statements to be upgrade specific, but how could I be specific about what enemy to target?
for the code I would need something like:
How should I make the variable nearby enemy, basically.
And also how could I prevent the crescent from messing up the targeting when there are multiple nearby enemies?
Hopefully it's understood what I want, I have an idea on how to do this, but not completely.
I have been slacking on game developing for a while and I'm ready to get back into it for a little bit.
So, what I need help doing is targeting any nearby enemy with a crescent (a projectile weapon). I want to have an upgrade for the crescent that starts constantly moving towards an enemy (like heat seeking missiles or whatever). Usually the crescent just goes in one direction only changing direction by colliding with something. But I want this to kind of pull towards a nearby enemy when the upgrade is active.
I know that for the actual following I would just have to have directional velocity and an angle in the draw actor of the crescent with some if statements to be upgrade specific, but how could I be specific about what enemy to target?
for the code I would need something like:
- Code: Select all
directional velocity=10;
angle=direction(x,y, Nearby Enemy.x, Nearby Enemy.y);
How should I make the variable nearby enemy, basically.
And also how could I prevent the crescent from messing up the targeting when there are multiple nearby enemies?
Hopefully it's understood what I want, I have an idea on how to do this, but not completely.