How do I place nodes where I want

Get help using Construct 2

Post » Thu Jul 09, 2015 5:16 pm

Hello and Sorry,
Cause this subject could be a bit repeated. Whatever i just want to place the nodes (pathfinding behavior) in the place i want so it will become like a path my object should move along. Need for solution ! :lol:
B
6
Posts: 38
Reputation: 338

Post » Thu Jul 09, 2015 6:19 pm

Add sprite, waypoint, add var waypoint.number
Place the waypoints on your layout and edit the variable number for all waypoints in the layout editor accordingly so it becomes the path you want.


Then add a variable to your player object with pathfinding. Player.waypoint. Set default to 1.

When you start the route
player find path to player.waypoint

And add


on pathfinding arrived
add 1 to player.waypoint
player findpath to player.waypoint.


If you want a loop, like a racing track, and say you have 20 waypoints, you could make instead of the above:


on pathfinding arrived
sub
-player.waypoint = 20, set player.waypoint = 1
sub else
-add 1 to player.waypoint
blank sub
-player find path to player.waypoint
Last edited by lennaert on Thu Jul 09, 2015 6:21 pm, edited 2 times in total.
Who dares wins
B
57
S
17
G
21
Posts: 1,878
Reputation: 19,572

Post » Thu Jul 09, 2015 6:19 pm

I don't think there are any way to manipulate nodes after a path have been found, however not 100% sure. If that is the case there are no "easy" solution to what you want to do. At least not easy enough for me to make an example :D

However here are some ideas that you can work with trying to find a solution.

Using several path findings:

Since you can get the nodes from path finding, what you can do is to first find a path to your final destination. Once that is done, you have all the nodes that C2 uses. You then go through each of these, beginning with the one closes to your object, to avoid having to path find to much. So using your conditions to decide whether a node is correct or need to be changed. Using the following rules:

1. (Node is correct) Store node in a Path finding list/array, Check next node.

2. (Node need to be changed) Make a dummy object to path find from the last added node in the path finding list to the new node location and then repeat the process creating the final path finding list.

You just have to be sure that the list you create is of course linked to the correct object.

Predefine path
Using a somewhat similar method as above. Using a path finding list.

But if you know the conditions that you want use you can add the node locations to the list and then path find through it as above.

Cost
This depend on what you are trying to do. But the path finding allows you to use cost which you can use to control what path it prefers. So maybe you can use some blocking sprites with high cost and place them where you don't want the object to move. But it of course highly depending on what you are trying to do.

Anyway just some ideas of how you can do it.
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,848

Post » Thu Jul 09, 2015 6:22 pm

nimos100 wrote:I don't think there are any way to manipulate nodes after a path have been found, however not 100% sure. If that is the case there are no "easy" solution to what you want to do. At least not easy enough for me to make an example :D


Including my previous post:

Pick waypoint.number = X , set position X,Y ;)

allthough, its not editing the nodes of the actual found path.
Who dares wins
B
57
S
17
G
21
Posts: 1,878
Reputation: 19,572

Post » Thu Jul 09, 2015 6:25 pm

lennaert wrote:
nimos100 wrote:I don't think there are any way to manipulate nodes after a path have been found, however not 100% sure. If that is the case there are no "easy" solution to what you want to do. At least not easy enough for me to make an example :D


Including my previous post:

Pick waypoint.number = X , set position X,Y ;)

allthough, its not editing the nodes of the actual found path.


Yeah that's good alternative, but it wouldn't be a bad idea if you could actually manipulate the nodes before using move along path. Ill add that to my list in general settings for "Object changes" :)
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,848

Post » Thu Jul 09, 2015 6:26 pm

Thank you all, guys.
B
6
Posts: 38
Reputation: 338


Return to How do I....?

Who is online

Users browsing this forum: AllanR, BackendFreak, R0J0hound and 26 guests