Unwalkable tiles using easystar, walk to nearest tile?

Get help using Construct 2

Post » Mon Jan 09, 2017 2:25 pm

99Instances2Go wrote:You made some weird mix with events from both methods.
Event 57 & 58 are left overs from method 1.
You forgot the 'on path not found' situation from method 2.

The 'marker' is just a debug object. You know that eh.

https://www.dropbox.com/s/8wyg0y99z065l ... .capx?dl=0

Now that is GOOD! I must have screwed up when I copied it, mistaking it for being because the object is bigger than the tile. I'm quite pleased the system inherently works by using the bottom pixel as the only reference, cos it makes it loads easier for implementing like this.

Okay, @99Instances2Go last trick and I'm done! You've helped spectacularly on this, now there's one final question. Is there a way of being able to move the character by the pixel IF the player is already in a tile, and you're clicking within the tile? If you notice here:
Image
He's just moving to the pixel, that way when you click close, the character doesn't stand still, but if you click to another tile, he'll still move there with pathfinding. I think I just need to know how moveto directly to the position within the tile, if you're already at the tile you're trying to pathfind to.
B
41
S
12
G
14
Posts: 1,117
Reputation: 11,253

Post » Wed Jan 11, 2017 8:50 am

@99Instances2Go alternatively, could the end node always be whatever offset to the Center of the tile you click is? That way the character should always walk even a pixel within the tile and arrive at precisely the point t on the tile clicked?
B
41
S
12
G
14
Posts: 1,117
Reputation: 11,253

Post » Sat Jan 14, 2017 11:06 am

With a tilemap based pathfinder ? I dont see it.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Sat Jan 14, 2017 12:32 pm

99Instances2Go wrote:With a tilemap based pathfinder ? I dont see it.

But is there a way of being able to test if the player is already on the tile you've clicked, and if so, just do a straight moveto?
B
41
S
12
G
14
Posts: 1,117
Reputation: 11,253

Post » Fri Jan 20, 2017 1:20 pm

99Instances2Go wrote:With a tilemap based pathfinder ? I dont see it.

So, two questions:
  • Is it possible to find a path to the tile clicked + the extact position on the tile that has been clicekd for greater accuracy
If not, then/if so, also:
  • If the player is already at the tile clicked, can we use this to do a non pathfinding MoveTo the pixel clicked on the tile?
B
41
S
12
G
14
Posts: 1,117
Reputation: 11,253

Post » Fri Jan 20, 2017 2:48 pm

1/ Of course. Use two tilemaps. 1 for the show. Erase the tile in the base tile map, set the tile in the show tilemap, find path, when path found, set the tile in the base tilemap, erase the tile in the show tilemap.

2/ Yeah, do as above, find path to mouse.X and mouse.Y

But that is not gonna work for tiles that are surrounded with other tiles. Because they are obstacles. I have no idea if you have surrounded tiles. So you need 3 tilemaps.
1 to mark the border tiles, leaving the surrounded tiles errased, use that as obstacle map.
1 to fill the surrounded tiles.
1 as a temporary to move tiles, that are obstacles but that you dont want to be obstacles, to. And back again.

Alternative, once they reach the second last index of the points in the calculated path, just move them to the stored mouseX/mouseY

But that is so way off from what you wanted in the first place.

So, or adjust the tilemap so a path can be found. Or, make the last move a straight move to the mouse.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Fri Jan 20, 2017 3:43 pm

On second thought. I can not wrap my mind on that question. What you do/want is this (illustrated) :

We stand on the side of a loch. You say: go as close as you can to that point in the water on the other side. But dont get wet, avoid water.

I take look at the map. Loch Lomond. Loch Morar. Loch Ness. That is gonna be a serious walk.

After 3 hours, i am there. Now you say, jump into the water to where i said that you should end the journey. So, i jump.
But now i am wet. So i stand there in the water.

Now you say: go as close as you can to that point in the water on the other side. But dont get wet, avoid water.

Eh? I should have taken a boat. But then i have to avoid land.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Fri Jan 20, 2017 10:35 pm

99Instances2Go wrote:On second thought. I can not wrap my mind on that question. What you do/want is this (illustrated) :

We stand on the side of a loch. You say: go as close as you can to that point in the water on the other side. But dont get wet, avoid water.

I take look at the map. Loch Lomond. Loch Morar. Loch Ness. That is gonna be a serious walk.

After 3 hours, i am there. Now you say, jump into the water to where i said that you should end the journey. So, i jump.
But now i am wet. So i stand there in the water.

Now you say: go as close as you can to that point in the water on the other side. But dont get wet, avoid water.

Eh? I should have taken a boat. But then i have to avoid land.

:lol:

99Instances2Go wrote:1/ Of course. Use two tilemaps. 1 for the show. Erase the tile in the base tile map, set the tile in the show tilemap, find path, when path found, set the tile in the base tilemap, erase the tile in the show tilemap.

2/ Yeah, do as above, find path to mouse.X and mouse.Y

But that is not gonna work for tiles that are surrounded with other tiles. Because they are obstacles. I have no idea if you have surrounded tiles. So you need 3 tilemaps.
1 to mark the border tiles, leaving the surrounded tiles errased, use that as obstacle map.
1 to fill the surrounded tiles.
1 as a temporary to move tiles, that are obstacles but that you dont want to be obstacles, to. And back again.

Alternative, once they reach the second last index of the points in the calculated path, just move them to the stored mouseX/mouseY

But that is so way off from what you wanted in the first place.

So, or adjust the tilemap so a path can be found. Or, make the last move a straight move to the mouse.

I think the most effective thing would be to, as you suggest, make a straight move to the mouse, but I don't know how to condition if the player is already on the tile. Obstacles won't be much of a problem I don't think because it only seems to care about the origin point, but it would be fun to see if the player gets stuck or not, I just don't know how to try this.
B
41
S
12
G
14
Posts: 1,117
Reputation: 11,253

Post » Fri Feb 10, 2017 4:17 pm

@99Instances2Go this'll prolly go down like a sack of hammers, but how do I reduce the tile size without the character running off to the corner of the screen when you click on an unwalkable tile?
B
41
S
12
G
14
Posts: 1,117
Reputation: 11,253

Previous

Return to How do I....?

Who is online

Users browsing this forum: richardfu and 32 guests