How do I stop my enemy in range of the player?

0 favourites
  • 4 posts
From the Asset Store
Player's Follower
$7 USD
30% off
Players follower. use it for anything which follows the player
  • Hi,

    I'm using a turret behaviour on my enemies to have them detect the player, turn to him and (on Turret shoot) resolve a path towards him.

    Now I want them to stop at a certain distance from the player. So far I've been using a second turret behaviour, but this has a lot of side effects that I need to fix and is not ideal.

    The easiest way I figure is using a dedicated collision check to fake a distance check in order to disable the approach behaviour. But I don't see an elegant way of assigning each enemy a sprite of type-depedant sizes, other than a seperate loop to place a radius sprite on each enemy each tick.

    Any suggestions how best to go about a radius check per enemy?

  • You could use the "System:pick by comparison" condition with the distance() equation and an enemy "range" instance variable.

    Ex.

    System: pick Enemy by comparison distance(enemy.X, enemy.Y, player.X, player.Y) < enemy.range

    --- enemy stop

  • Hey,

    this is a usefull sample:

    https://www.scirra.com/tutorials/1022/c ... form-games

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • the expression is of course a good idea, not really aware of all the methods C2 provides there.

    now i'm trying to sort this in a wanna-be state machine, but somehow I still can't get my enemy to stop in range.

    [attachment=0:1bneadhf][/attachment:1bneadhf]

    why is the pathfinding behaviour not stoppable by either 'stop' nor 'disabeling' the behaviour?

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