How do I move to the next point with pathfinding

0 favourites
  • 4 posts
From the Asset Store
Connect the dots in the correct order and draw happy animals!
  • Hi!

    I'm wondering if there's a way to let a pathfinding object, move to different points and not only one? So lets say I place 10 copies of one sprite, and then have

    an enemy move to each and every point with pathfinding? And then at the last point available, reverse the same route and keep doing this infinitely?

    Is this possible and how in that case?

    Thanks!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Yes that is possible.

    The Pathfinding behavior has the Expressions

    NodeXAt

    NodeYAt

    Return the position of a node in the path that was found, in layout co-ordinates, using the zero-based index of the node. This is only available after On path found.

    And

    NodeCount

    The number of nodes in the path that was found. This is only updated after On path found.

    So, with NodeCount you know how many waypoints are in a path. If you want the coordinateds from point 2.

    That is NodeXAt(2) & NodeYAt(2)

    Now, to move to them is another story.

    I would use .

    Why? because (i did not try this one, but all rexrainbow 's plugins have the same great features) it has a condtion 'On arrived'. Wich is pretty easy and lovable.

    So, your objects need a instance variable that knows wich node they are supposed to go to.

    Add 1to that variable when it arrives. NodeCount tells you wich is the last one.

    Send it moving to NodeXAt(instance variable) & NodeYAt(instance variable)

  • Hi!

    Thanks for your tips! I appreciate that!

    I started thinking, it might be better if I go some other route at doing what I'm trying to achieve.

    Ill explain what I mean so it's easier to understand what I'm trying to achieve. I'm having this enemy eagle character that I want to be flying around forward and back, but in a specific path, and preferably smoothly.

    Here's a edited screenshot to show you what I mean:

    Do you have any suggestions on how I could achieve that? What behaviors would be best?

    Thanks!

  • Set a few invisible objects. Move from object to object with the the behaviour i allready pointed to:

    Look at the demo and the capx provided.

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