0 Favourites

How do I make path finding pick a nearest/furthest target?

  • Lets say I have some villagers spawning from a boat and I want them to find a path to the furthest forest to gather wood and then find a path to the nearest plot to build.

    How would I have them pick nearest or furthest before setting a path?

    This could also be used when fighting things trying to attack the village. I would like to limit the villagers to attach the nearest enemy.

    Any thoughts?

    Thank you!

  • add event, choose the forest sprite, look for "pick nearest/furthest"

    then for the action, find the path.

  • add event, choose the forest sprite, look for "pick nearest/furthest"

    then for the action, find the path.

    Sometimes I assume the goal is so unobtainable I end up overthinking how to get there. Thank you, let me try it later today and I'll get back to you!

  • add event, choose the forest sprite, look for "pick nearest/furthest"

    then for the action, find the path.

    This actually isn't working. I found that I can pick nearest/furthest with the path finding object but then I need to tell it where to set the path once it's picked the nearest and during this phase I can't tell it to go to the "picked" object.

    Can you upload a CAPX?

  • TheSynan Are you picking nearest/furthest the forest, or the pathfinding villagers?

    I opened up the pathfinding example and put in an event which went something like this:

    obstacle (not pathfinding object) pick furthest to obstacle.x, obstacle.y

    then for the action I had sprite (pathfinding object) find path to obstacle.x, obstacle.y

    This works (I did have to delete the obstacles off to the side, it couldn't find a path to them for some reason, but that's irrelevant unless you want to replicate it in the pathfinding example...)

    so replace "obstacle" with "forest" and "sprite" with your villagers and it should work.

    EDIT: No wait, I confused that... it should go:

    obstacle, pick furthest to SPRITE.X, SPRITE.Y (not obstacle.x and y as I said above)..

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • TheSynan Are you picking nearest/furthest the forest, or the pathfinding villagers?

    I opened up the pathfinding example and put in an event which went something like this:

    obstacle (not pathfinding object) pick furthest to obstacle.x, obstacle.y

    then for the action I had sprite (pathfinding object) find path to obstacle.x, obstacle.y

    This works (I did have to delete the obstacles off to the side, it couldn't find a path to them for some reason, but that's irrelevant unless you want to replicate it in the pathfinding example...)

    so replace "obstacle" with "forest" and "sprite" with your villagers and it should work.

    EDIT: No wait, I confused that... it should go:

    obstacle, pick furthest to SPRITE.X, SPRITE.Y (not obstacle.x and y as I said above)..

    Thank you!

    It works. I had a hell of a time with instance variables and having the "villagers" find a new path but I got it working. Thank you!

    Now on to working out LOS crap haha.

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