Making an RTS object move to a point within range.

This forum is currently in read-only mode.
  • 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?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

  • 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?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)