How do I move to the next point with pathfinding

Get help using Construct 2

Post » Thu Jun 30, 2016 9:58 am

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!
Image
B
12
S
3
Posts: 40
Reputation: 847

Post » Thu Jun 30, 2016 11:04 am

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 behavior-rex-spline_t178563.
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)
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Thu Jun 30, 2016 6:52 pm

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:
Image

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

Thanks! :)
Image
B
12
S
3
Posts: 40
Reputation: 847

Post » Thu Jun 30, 2016 10:31 pm

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

behavior-rex-spline_t178563

Look at the demo and the capx provided.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950


Return to How do I....?

Who is online

Users browsing this forum: dop2000 and 31 guests