[Path finding] Why doesnt this work?

Get help using Construct 2

Post » Tue Oct 07, 2014 1:47 pm

I have some problems with the path finding, and cant see why it doesn't work as it should according to the manual if I understood it correct.

Image
There are 2 objects that are told to go somewhere near the X. Both have path finding and set to custom Obstacle, the tilemap doesn't have solid behaviour, not that it makes any difference.

Image
From the manual:
Obstacles
If Solids, the behavior will automatically mark cells touching objects with the Solid behavior as being obstacles. If Custom, you must define which objects are obstacles by using the Add obstacle action on startup.

So I tell Object 1 to add the tilemap as obstacle and clear all obstacles for object 2, which shouldn't be needed in the first place.

Add obstacle
If the Obstacles property is Custom, add an object to mark as an obstacle in the pathfinding grid. If this is done during the game (after Start of layout), you must also use Regenerate obstacle map for it to take effect.

Since this is done at start of layout Regenerating the obstacle map for Object 1 doesn't need to be there. I was just testing.

Clear obstacles
Remove all obstacle objects added with Add obstacle. You must also use Regenerate obstacle map for this to take effect.

So in desperation I added Regenerate obstacle map for both objects which again shouldn't be needed.

However when I run the program, regardless of adding all the actions that shouldn't have to be there or removing them.

The objects behave like this:
Image
The red object behaves as it should, however the green object insist of also seeing the tilemap as an obstacle. And I cant figure out why it does that. As it clearly state in the first quote:
If Custom, you must define which objects are obstacles by using the Add obstacle action on startup

None of the objects are part of a family or anything they are 2 separate objects.

Anyone know why the green object behaves like that?
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,848

Post » Tue Oct 07, 2014 2:11 pm

I think it is a bug. Seems like there is only one global pathfinding obstacle map and not instance specific. Even if another is set to solid and other for custom it doesn't seem to work.

Perhaps an oversight after regenerate region feature?
B
34
S
9
G
3
Posts: 517
Reputation: 5,276

Post » Tue Oct 07, 2014 2:20 pm

Katala wrote:I think it is a bug. Seems like there is only one global pathfinding obstacle map and not instance specific. Even if another is set to solid and other for custom it doesn't seem to work.

Perhaps an oversight after regenerate region feature?

Yeah you might be right, I cant recall if I have had this problem before. :(

But I cant figure out if its just something I have forgotten to check, but have use the path finding behaviour so much, that I would be surprised if that was the case, also why I ended up checking the manual to see if I had forgotten something. But cant see that there should be anything wrong with what im trying to do.

I also tried to move Clear obstacles for the green object to the On key pressed event and regenerate it there according to the manual, but doesn't make any different.
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,848

Post » Tue Oct 07, 2014 2:35 pm

Pretty sure its a bug, did some more testing.

Image
Added another object to test against collision with.

Image
If I tell that the green object should collide with it, it doesn't react at all. However if I disable that and enable that Red object should collide with it, both of them again try to avoid it.

Image

However now it gets even weirder :D
If I change the code like so.
Image

They behave like this, and just completely ignore the tilemap :o
Image
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,848

Post » Tue Oct 07, 2014 2:51 pm

Seems to have something to do with that it only take the first object into account. The red object was the first one added and if I delete that from the project the path finding works again. However now its just does the same with the green object as its now the first object, so if I add another object again. Then the green object is controlling the path finding and that one bugs again.
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,848

Post » Tue Oct 07, 2014 2:57 pm

Could be good to make a bug report before next stable release.
B
34
S
9
G
3
Posts: 517
Reputation: 5,276

Post » Tue Oct 07, 2014 2:59 pm

Yeah making one now :)
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,848

Post » Tue Nov 11, 2014 5:21 pm

Hello there,

I was wondering if you were able to find a solution? I stumbled on the same problem as you did. I tried many different actions and settings with not resulting in a solution. Looking at you're example:

I made something similiar as you did, the only thing I added that I made more objects. For example I made two Obj_1 and two Obj_2, I made an action; Obj_1 adds Obj_1 as obstacle. Second action: Obj_2 adds Obj_2 as obstacle.

In this example, Obj_1 should be able to move through any Obj_2 but not through Obj_1. And same is vice versa. Obj_2 should be able to move through all Obj_1s but not through Obj_2. I can not seem to get it working properly.

Any new advise?
B
4
Posts: 1
Reputation: 206

Post » Sat Nov 15, 2014 8:32 pm

Matsu wrote:Any new advise?

Unfortunately i dont think its possible to make a workaround, as its part of how C2 uses obstacle maps. As Ashley have pointed out here in the bug report.
The problem is there is only one global obstacle map used for the pathfinding behavior. Everything pathfinds on the same map. So if you have object A with two obstacle types, and object B with no obstacle types, you have a conflict: should the one global map have those objects as obstacles, or not? In this case it happens to pick the global map where no obstacle types are defined. If you delete the red object there's no conflict any more and it uses the right obstacles.

I'm not sure how to resolve this - having multiple maps becomes memory inefficient and possibly slower, but on the other hand perhaps the obstacle types should be global as well to avoid this situation... the easiest thing to do is to make sure you have the same obstacles added for every object using the pathfinding behavior.

I dont know what state the pathfinding behaviour is in, since there are some other problems with it as well. But hopefully (fingercrossed) they are working on a new more solid version, that makes of for these things. And since im mostly interested in making games where pathfinding is needed, i have limited myself to only work with tilebased turn-based types of games as you can avoid at least some of the problems. But in most other types of game (real-time), it will end up with you having to give up the project or having to make some serious work around for some of the other problems, but still the problem in this thread cant be solved as it is now, as I understand Ashley answer. So you have to design your game based on these problems which I don't really want to do.
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,848

Post » Sun Oct 04, 2015 8:11 pm

Couldn't u define the obstacles for each sprite?
B
11
S
2
Posts: 38
Reputation: 661

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 25 guests