Problem Using Pathfinding

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

    I was trying to create a 'very' simple goal system, the sprite starts at home, goes to the dungeon, and stays there until their health got low or they got enough gold to buy something.

    But I can't get the AI moving just with pathfinding.

    dropbox.com/s/if8r2os8czlh7kk/Pathfinding.capx

    In the example you can control a sprite to visit dungeon for gold but loose health, store if you have 100 gold and home will heal if your injured and each place acts like it should.

    The AI is pathfinding (only different it gets gold from the home and health from the Dungeon), it knows where its going, but its just not going there, add bullet behavior and it will move along the pathfinding, but bullet is not ideal

    I am sure I am doing something very basic/silly but I am just not seeing it, I looked at the examples and searched the forum but yeh its got me stuck.

    Any help would be appreciated.

    This is the demo version, using chrome..so if that does make a difference let me know, but I couldn't see any reason it should.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I found my problem..I was constantly finding a path so it was to busy looping over that to actually do any movement.

    When you have it in response to say a mouse click, it registers the click and finds a path, then find a path triggers and it starts moving along it, but I had when health was less then 5..so it just keep finding a path while health was less then 5 and not actually moving along it.

    The fix I did and please let me know if there is a better one, 2 boolean variables

    'In trouble' and 'Going Home'

    In Trouble would set to true if health was 5 or less.

    But the pathfinding would only run if Going Home was set to false.

    In the script I find a path and set Going Home to true, so it can no longer try and find a path, since going home is now true.

    After its home and healed, set both In Trouble and Going Home to false, they will not re-trigger because its full health, and then do the reverse to trigger the go out and hunt.

    i would post the capx but I rushed what I did so its in a bit of shambles, but if someone wants it just reply back.

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