pathfinding behaviour setup.

0 favourites
  • 4 posts
From the Asset Store
A whole set you need to create a gorgeous winter 2d game
  • Hi all.I can get the pathfinding behaviour to work almost as I wanted.The only problem I have is that I want the object following the path to move in rigid horizontal and vertical lines.At the moment when the object reaches a point where it has to change direction it sort of swings around the turning point rather than just immediately reaching one node point going in one direction and then setting off in the other direction.I should clarify that this is a grid based game with each grid being 64pxx64px.I also have rotation in the pathfinding object set to disabled.I hope someone can help.

    Richard

  • If I am not mistaken, disable the diagonals and increase rotate speed on the pathinding.

  • I have already disabled diagonal movement.What speed do you suggest setting the rotation to?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I just tested what you are actually trying to do as far as i can understand. And had the same problem as you had, unfortunately I weren't able to fix it either, as it seems to be hardcoded into how the pathfinding behavior works, so it seems to want to smooth the movement.

    In general the behavior need a bit of updating in my opinion, it seem to be in a state of "just" being useful, with all the feature that would make it very useful not being there, but hopefully they will update it soon.

    However depending on how you want to use it in your game, you might be able to use some of it.

    In the testing I did, I wanted a "unit" to move around like you would see it in a game like Dwarf fortress, so its not based on "over time" movement. but 32 pixel at the time. If that is what you are looking for. You can use the path finding to find the path for you, and manually move the unit yourself, using very simple "If statements".

    In my test i used a tilemap, which give you a grid from 0 - X, 0 - Y and you can transform a sprites(X,Y) to these tiles. So what you can do is to transform the nodes from the pathfinding into these tiles coordinates, and use these to know where to move the sprite.

    So if the pathfinding find 2 nodes to reach the destination, which converted to the tile coordinates are:

    (0,5) and (5,3)

    And your sprite is at 0,0 (tile coordinate)

    You can simply check if the sprite X value is the same as the first node X value, if that's the case you check the Y value, since the node Y value in this case is 5. You can add 1 to the sprites Y value, so now its at (0,1) and you just keep doing that until the sprites position is the same to where you want it to go.

    I guess you could add animation to it, if you wanted but i haven't tried that.

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