pathfinding behaviour setup.

Get help using Construct 2

Post » Tue Feb 04, 2014 1:45 pm

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.

Richardwestray2014-02-04 13:47:09
B
28
S
2
G
3
Posts: 61
Reputation: 2,523

Post » Tue Feb 04, 2014 6:00 pm

If I am not mistaken, disable the diagonals and increase rotate speed on the pathinding.
Who dares wins
B
57
S
17
G
21
Posts: 1,878
Reputation: 19,562

Post » Tue Feb 04, 2014 9:18 pm

I have already disabled diagonal movement.What speed do you suggest setting the rotation to?
B
28
S
2
G
3
Posts: 61
Reputation: 2,523

Post » Tue Feb 04, 2014 11:56 pm

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.
nimos1002014-02-04 23:57:40
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,828


Return to How do I....?

Who is online

Users browsing this forum: bluesun66 and 4 guests