Basically, I'm making a simple RTS, nothing fancy. Right now the player can click on an enemy unit to send his units to attack, but I'd like them also to move to a point within the range of the enemy unit, rather than moving directly to it.
This image explains it fairly well.
http://i150.photobucket.com/albums/s117 ... intlol.jpg
The red is the enemy, green squares are the player's units, and the blue circles with lines are the destination I want the green squares to end up at if the player sends them to attack the enemy.
I know from using Game Maker years ago that it had handy little lengthdir_x and lengthdir_y commands for just such an occasion, so is there something similar in construct?
This can be done using a little math. I'm not so good at explaining these things, so here's a CAP file I whipped up real quick:
RTS in Range
The goodguys have a variable called 'range'. Changing this will change the distance at which they stop.
Hope that helps.
Develop games in your browser. Powerful, performant & highly capable.
That works perfectly! Thanks!
I'm not very good with math, so I would probably have spent hours trying to come up with something like that.
Now, supposing I wanted to make this work for NPCs too, would this make the NPC go after the closest player unit, or to the first created?