How do I make enemy move toward player then stop to attack

0 favourites
  • 2 posts
From the Asset Store
Basic Rounded Vector Geometry Player Design with Glow for 3 player games
  • Goodmorning, I have been researching this for a couple of days and I don't understand what I am doing wrong. My enemy moves up and down but he does not move left or right. I am making a 4 direction rpg. I also need help with creating a threshold so that when the enemy gets x amount of pixels away he starts attacking.

    If someone can please explain what the conditions and actions should be or make a capx or screenshot I would really appreciate it.

    This is what I have

    Tagged:

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hey, it's because 2 of those are always going to be true at the same time and you can't simulate in 2 directions at once, it picks the last events as they run last so up/down. You'll need to apply some different logic for that so for example when the Y is the same then it starts adjusting the x to move left/right.

    To stop and attacking you can use distance(player.x,player.x,enemy.x,enemy.y) is a value, and when it hits that value you set the enemy to a different state. This could be an instance variable that changes between 'moving' and 'attacking'.

    Then for the movement logic you add a condition, enemy.state is not 'attacking'. This allows the enemy to stop moving and attack instead.

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