Run away, he's unstoppable!?

This forum is currently in read-only mode.
From the Asset Store
Full game Construct 2 and Construct 3 to post on Google Play
  • Within my enemy AI group I want to have an event that tests if the enemy's health is below a certain level, then it makes them flee.

    But that's just the problem, see, I could simply test the player's x and y coordinates relative to the enemy and then have the enemy move in the proper direction but that's 4-6 different events, I was hoping there is a more efficient way of doing such a thing, with perhaps only ONE event.

    So the idea is, with an RTS movement event "move to position", what, my good sir might I enter in the X and Y coordinates boxes to make the enemy move AWAY from the player?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • This formula should do essentially what you're looking for:

    X: enemy.x + cos( angle(player.x, player.y, enemy.x, enemy.y) ) * 100

    Y: enemy.y + sin( angle(player.x, player.y, enemy.x, enemy.y) ) * 100

    This will have the enemy move in the most "away" direction as possible from the player.

  • That was exactly what I wanted, thankyouz!

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