[SOLVED] Ranged attack question

This forum is currently in read-only mode.
  • In my game there are enemies who attack in melee and rangers. Melee opponents work just fine but I've encountered problem with rangers. I'm using Line of Sight behavior for targeting and attacking and Platformer for movement. If there are several rangers near the player instead of all only one of them attacks. What is the reason?

  • Can you post a screenshot of that situation? It sounds like they are blocking each others line of sight if they are all solid and your line of sight behaviour says to collide with solids.

  • Its probably because line of sight doesn't work well with multiple instances.

    Since this is platform, and you probably only need a single axis to compare, try the overlapping at offset condition. Like ranger is overlapping at offset enemy 30x 0y.

    Then -30x 0y for the left side.

    If you do need both axes then you can use distance(x1,y1,x2,y2), but you may need something else to pick.

  • Can you post a screenshot of that situation? It sounds like they are blocking each others line of sight if they are all solid and your line of sight behaviour says to collide with solids.

    They are not solid<img src="http://img109.imageshack.us/img109/86/40666126.png">

    The left one is shooting second bullet on this screenshot while the right one isn't shooting at all.

  • Its probably because line of sight doesn't work well with multiple instances.

    Since this is platform, and you probably only need a single axis to compare, try the overlapping at offset condition. Like ranger is overlapping at offset enemy 30x 0y.

    Then -30x 0y for the left side.

    If you do need both axes then you can use distance(x1,y1,x2,y2), but you may need something else to pick.

    I tried that but situation is the same

  • I've got it! The problem is in spawn another object event! It seems that only one enemy could be a "bulletspawner" at the same time! Any suggestions how to fix it?

  • I've got it! The problem is in spawn another object event! It seems that only one enemy could be a "bulletspawner" at the same time! Any suggestions how to fix it?

    Create a "For each object" loop and select the shooters. Then put your shooting event inside of that loop. This will make each enemy shoot when they have LOS.

  • > I've got it! The problem is in spawn another object event! It seems that only one enemy could be a "bulletspawner" at the same time! Any suggestions how to fix it?

    >

    Create a "For each object" loop and select the shooters. Then put your shooting event inside of that loop. This will make each enemy shoot when they have LOS.

    It causes crash! Debugger tells me that it may be bug in Construct...

    By the way here is a screenshot with my event

    <img src="http://img863.imageshack.us/img863/9876/13818243.png">

  • Hmm, now it looks like a bug with the LOS behaviour. I've had similar problems in my game using LOS

    Maybe have a variable "HasLOS" for each object, then check if that variable is true. Then, outside of the for loop have the condition "En6box Has LOS to Player" and action "HasLOS = True" and then another condition below "Else" with action "HasLOS = False".

  • Hmm, now it looks like a bug with the LOS behaviour. I've had similar problems in my game using LOS

    Maybe have a variable "HasLOS" for each object, then check if that variable is true. Then, outside of the for loop have the condition "En6box Has LOS to Player" and action "HasLOS = True" and then another condition below "Else" with action "HasLOS = False".

    Crash anyway

  • Sorry it appears my understanding of overlapping at offset was wrong.

    As it is now overlapping at offset only checks for a single point, not all points between.....

    Here is an cap using dummies instead.

    http://dl.dropbox.com/u/666516/fakelosplatform.cap

    Should be fairly straight forward, cept angle(x1,y1,x2,y2), which gives you the angle.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You have my eternal gratitude newt!!!

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