How do I place nodes where I want

0 favourites
  • 6 posts
From the Asset Store
Forgotten Place - Melodic ambiance, background music, Synth
  • 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 !

  • 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

  • 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

    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.

  • 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

    Including my previous post:

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

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

  • > 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

    >

    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"

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thank you all, guys.

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