Simplest pathfinding around a tilemap track

1 favourites
From the Asset Store
This is a black tileset with 2 tilemaps, props, one animated character and more.
  • I don't see any odd reason..

    Pathfinding finds the shortest path, so if you don't close off the direction to the finish it will go directly to it..

  • I don't see any odd reason..

    Pathfinding finds the shortest path, so if you don't close off the direction to the finish it will go directly to it..

    I'm going to work with your bullet idea, but I tried working it into using the pathfinding motion (since I liked the little rotations on the corners) but the sprite AI has a little think before it goes around again (kinda cute) whereas a fluid continuation would be better, not sure I can do that though? https://www.dropbox.com/s/sxwl936plk26u ... .capx?dl=0

  • I don't see any odd reason..

    Pathfinding finds the shortest path, so if you don't close off the direction to the finish it will go directly to it..

    LittleStain perhaps the easier question would be, is it possible to interpolate the angles of rotation? at the moment with the bullet movement, the sprite just jumps to the angle it's going, whereas with pathfinding it smoothly changes the angle. Perhaps with lerp?

  • I wouldn't use lerp (or anglelerp in this case), but if you want to try, go ahead..

    Maybe you could use rotate counterclockwise while within a certain distance of the node untill the right angle is reached..

  • I wouldn't use lerp (or anglelerp in this case), but if you want to try, go ahead..

    Maybe you could use rotate counterclockwise while within a certain distance of the node untill the right angle is reached..

    That's what I was thinking, maybe something like [quote:2kftm5zj]anglelerp(Self.Angle,TargetAngle,8*dt)

    but I'm not sure how to use this in a condition with the current system?

  • I said I would NOT use it, so why give an example in which it is used?

    So like I said, what you could do is check the distance to the currentdestinationnode (actually there is already an event doing that) and instead of setting the angle directly rotate 1 degree counterclockwise untill the new angle is reached..

    Should be pretty easy to make..

  • I said I would NOT use it, so why give an example in which it is used?

    So like I said, what you could do is check the distance to the currentdestinationnode (actually there is already an event doing that) and instead of setting the angle directly rotate 1 degree counterclockwise untill the new angle is reached..

    Should be pretty easy to make..

    Okay, I wasn't entirely sure if you meant it should be used or not, sorry. Why counterclockwise? What if the "bullet" is going from, say, 90° angle to 0°, wouldn't that be a clockwise rotation?

    I'm trying to figure out how these expressions work, but it's slightly confusing to me how it's been written with distances and destinations, as I said, I'm okay with the basics, but detailed expressions are a bit difficult for me to manage, which is why I put this in the beginner's section, it's really not my strong point yet. Most things I try in C2 that aren't from the context menus tend to not work anyways, I usually forget to wait 0.1 seconds and events cancel each other out, so I'm sorry if I'm slow but I am trying to comprehend how these more advanced (to me) algorithms work.

    As you say, there is the currentdestinationnode check (Turt.Pathfinding.NodeCount-1) but I have no idea how to gradually rotate the bullet when it's a) using a bullet behaviour and b) it's angle seems controlled by variables. I can probably get it if you can hint whereabouts I should put these events/conditions.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I said I would NOT use it, so why give an example in which it is used?

    So like I said, what you could do is check the distance to the currentdestinationnode (actually there is already an event doing that) and instead of setting the angle directly rotate 1 degree counterclockwise untill the new angle is reached..

    Should be pretty easy to make..

    LittleStain Okay, I've managed to get it rotating with the rotate towards angle of motion, but obviously it only starts rotating when it's changed direction, whereas in order to be as effective as the pathfinding angle rotation, it would need to have a type of 'lookahead' whereby the sprite knows the next sequential direction it will be moving in, and could start rotating when it's within, say, 20 of the destination node. Is this possible using some of the data extracted from the pathfind?

  • As stated before, what you'd need is an event "if within a certain distance of the destinationnode rotate towards the position of detinationnode+1"

  • As stated before, what you'd need is an event "if within a certain distance of the destinationnode rotate towards the position of detinationnode+1"

    https://www.dropbox.com/s/eytk0omy9wvlt0x/pst.capx?dl=0

    I used this:

    but it never gets to the right angle, even though it tries?

  • Seems like you are almost there..

    You could now add a "is not within angle" condition..

    then add an else event and set the exact angle..

  • Seems like you are almost there..

    You could now add a "is not within angle" condition..

    then add an else event and set the exact angle..

    I'm just not getting this?

  • Okay, I kinda got it working (looks like it's got some serious racecar drift going on since it's faking the rotation and it has no effect on it's motion) but the last little booboo is it twists at the end of the path. Tried doing some offset checks, but it keeps twisting anyways. Any ideas?

  • I think it's because the path find has to go to an image point, Finding the path to Finish.ImagePointX is saying ImagePointX does not take 0 parameters?

    EDIT: did it with Finish.ImagePointX(0) but the sprite is still rotating on the finish of the path?

    Here's a CAPX https://www.dropbox.com/s/p6ew8id1m9pus ... .capx?dl=0

  • Well, like in the bulletevent, you should check if you're not at the last node, because destinationnode+1 doesn't work there..

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