Does anyone have better pathfinding scripts for a top down game then this?

0 favourites
  • 8 posts
From the Asset Store
Units do not overlap each other and use different ways if there are several free ways.
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • "Enemy pathfinding is enabled" event on your screenshot runs on every tick, 60 or even more times per second. You should avoid finding path or changing PF obstacles on every tick! Check out the official examples on how to use Pathfinding behavior:

    https://editor.construct.net/#open=pathfinding
    https://editor.construct.net/#open=pathfinding-path-cost
    https://editor.construct.net/#open=template-real-time-strategy
    https://editor.construct.net/#open=tile-based-pathfinding
    https://editor.construct.net/#open=template-turret-defense 
    
  • So if I want the enemies to be constantly chasing the player I shouldn't be updating it every tick. Would I want it to update every like 10 ticks or so and use some wait commands to achieve that? Thanks for the help.

  • To approach this efficiently, think about when you would actually need to update pathfinding. For starters, if an object has line of sight, you don't need pathfinding at all.

    When line of sight is broken, run pathfinding for that instance only.

    Upon reaching the first node or corner, check again if you have line of sight or not, and run pathfinding again if not.

    Basically during the whole time the object is traveling to that first waypoint, running pathfinding again is useless because the result will be the same anyway.

  • To approach this efficiently, think about when you would actually need to update pathfinding. For starters, if an object has line of sight, you don't need pathfinding at all.

    When line of sight is broken, run pathfinding for that instance only.

    Upon reaching the first node or corner, check again if you have line of sight or not, and run pathfinding again if not.

    Basically during the whole time the object is traveling to that first waypoint, running pathfinding again is useless because the result will be the same anyway.

    Oohhhhh I get get! Thanks for the help! That should fix my problem. One problem I was having with my current code was when there got to be to many enemies on the screen some of them would just no longer move.

  • Ok so everything works except now the enemies are walking through the invisible walls I have set up. I have been messing around trying to get it to work and its still not working.

  • Alright I have been still trying stuff like changing around enemy settings and they are still going through walls.

  • Alright problem has been fixed! All I had to do was get rid of this piece of code that was setting the enemies to visually be behind the top wall. I only had that there for a test piece of code I forgot to get rid of it. Thanks for your guys help!

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