How to make enemies shoot player only when they are in range?

0 favourites
  • 5 posts
From the Asset Store
Shoot balls to destroy as many blocks as possible, at each stage the game will become more difficult.
  • Hello I am trying to make an enemy that will shoot the player when they come too close and stop shooting when they are out of range, I have tries using two techniques first with Line of Sight

    this somewhat works as enemies will start to shoot player when they come within range, however they will continue shooting even when the player moves out of the Line of Sight range and the instance boolean variable LOS remains true.

    I have also tried comparing distance variables as shown below

    this solves the previous problem but creates another. there are multiple enemies on the layout however only one enemy, the first spawned in, triggers this event, not only that but when this first enemy is within range, All enemies will begin to shoot player.

    I am fairly new to construct but am really enjoying it, im sure ive missed somthing obvious, if anyone can help me out I would be very appreciative. thank you

  • First screenshot looks fine and I don't see how it wouldn't work as intended. Only thing I can think of is that you've misunderstood the range and it's not actually out of range.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • First screenshot looks fine and I don't see how it wouldn't work as intended. Only thing I can think of is that you've misunderstood the range and it's not actually out of range.

    Thank you for your reply, i did double check the range (210 pixel) I have also pinned a circle to the enemies with a diameter of 420 pixels to help visualize the problem.

    here is the .c3p file, if its not too much bother would you or anyone else have a look at it?

    1drv.ms/u/s!AgLvvr9zxjifkQryF15ae90S2pnl

    I have set the wave count to a wave where these enemies can appear, however there is a slim chance the correct blue enemies may not spawn and the game will only choose red, it will have to be restarted if that is the case. thank you

  • It's because you have set solids as obstacles and the player is solid

  • It's because you have set solids as obstacles and the player is solid

    thank you so much that's solved it, I could kiss you

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