[Solved]AI and pathfinding distances

0 favourites
  • 4 posts
From the Asset Store
Units do not overlap each other and use different ways if there are several free ways.
  • Hello folks,

    Hopefully someone can help me with this.

    Basically, my issue is that the Enemy's do not stop pathfinding or movement when they get within a certain distance to the player. As far as I can tell the math is sound, it's a simple check to see if the distance is less than 5000 and greater than 450.

    Another check to see if it's less than 450 should stop the movement.

    Please note that the path finding TO the player works as expected

    Code is below, hoping i've missed something basic but if not, any suggestions?

    Cheers,

    Matt

  • Hmmm?

    What I see is your use of on pathfinding path found move along in line 284 is probably over riding your order to stop moving in line 285.

    I would add a global variable trigger to that to to stop the pathfinding completely when that distance is met.

    That should fix the problem.

  • 283 & 285

    You dont pick any EnemyShip in those 2 events. So they are un-referenced, which is the same as a 'pick all'.

    So, they all (each and every one) find a path every second (not that good for performance too) ...

    And, they all (each and every one ) stop when the condition is somehow true.

    System > Compare two values is only a logical condition, it has not 'pick' function.

    You need a 'for each enemy', but then you surely have to bundle 283 & 285 in one 'for each', else you gonna drop performance to turtle walk in the end.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks lads, sorted now.

    Looks like it was me being a bit special and not noticing I hadn't added a pick condition.

    lamar

    Done, thanks!

    99Instances2Go

    Thanks for pointing that out, i'll switch it to individual instances on screen (or close)

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