Enemy attacking range

0 favourites
  • 3 posts
From the Asset Store
Moles Attack game assets for 2D whack a mole smash and hit action fun game.
  • Hi, I have created an enemy.. got the enemy patrolling using edge markers, but I am unable to figure out how to get the enemy to fire if the player comes within a certain range of the enemy (line of sight kinda)

    The enemy shoots only on the X-axis while facing the Player.

    So, I wanted to know how to make the enemy fire at the player when the player reaches within certain pixels(?) of the enemy.

    Thanks!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Use the distance() expression.

  • Hi, I still was not able to get it right... can anyone give me a sample on how to use it? I dont think I am doing it the right way too.

    I have put instance variables (oldx and oldy) to player as well as the enemy. I have set values:

    PlayerBox: On Created -> Set oldx to PlayerBox.X

                          -> Set oldy to PlayerBox.Y

    And the same for enemy too.

    After this I dont know how to compare distances between the two objects. :( The distance says I have to input 4 values, whereas I just need to see if the distance between the two on X axis.

    Please help :)

    Thanks!

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