[Path finding] Why doesnt this work?

0 favourites
From the Asset Store
_______ Huge collection of metal fixtures ________
  • 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.

    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.

    From the manual:

    [quote:1qs6f342]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.

    [quote:1qs6f342]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.

    [quote:1qs6f342]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:

    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:

    [quote:1qs6f342]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?

  • 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?

  • 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.

  • Pretty sure its a bug, did some more testing.

    Added another object to test against collision with.

    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.

    However now it gets even weirder

    If I change the code like so.

    They behave like this, and just completely ignore the tilemap

  • 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.

  • Could be good to make a bug report before next stable release.

  • Yeah making one now

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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?

  • 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.

    [quote:1k8pd27s]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.

  • Couldn't u define the obstacles for each sprite?

  • Couldn't u define the obstacles for each sprite?

    No that's the problem there are only one obstacle map.

  • Not anything I've messed withthis , but if I understand your problem...defining the other sprite as an obstacle and refreshing around each every x seconds should work...or so I would think. Both sprites much be obstacles respectively. I've been running multiple copies of the same sprite and defining hits on overlap...works fine and kinda the same issue. Just havta be careful not to refresh the whole thing each time or you'll run at negative fps lol

  • Not anything I've messed withthis , but if I understand your problem...defining the other sprite as an obstacle and refreshing around each every x seconds should work...or so I would think. Both sprites much be obstacles respectively. I've been running multiple copies of the same sprite and defining hits on overlap...works fine and kinda the same issue. Just havta be careful not to refresh the whole thing each time or you'll run at negative fps lol

    It shouldn't matter whether you keep refreshing the obstacle map as there are only one. Besides that if you refresh it constantly you will most likely ruin performance.

    The problem occurs as each units might need to have different obstacles. Like a ship, plane and car.

  • nimos100 have you seen this tutorial?

    https://www.scirra.com/tutorials/1118/path-finding

  • nimos100 have you seen this tutorial?

    https://www.scirra.com/tutorials/1118/path-finding

    Not really sure what that solves, I assume you mean using path finding without obstacle map? but that pretty much ruins the whole purpose of it? Because in that example the path finding is just used to move a unit to the castle and stop when it hits it. But what if there are 5 castle behind each other and you want the guard to go to castle 4, then it will hit castle 1-3 and stop? But how would you make it move around the castle, if there are no obstacle map?

    This is not a self created problem and since the OP is really old back when C2 was r182, and I haven't heard or seen any updates that solves this problem and someone not long ago posted the same issue which made this old post appear again <img src="{SMILIES_PATH}/icon_e_biggrin.gif" alt=":D" title="Very Happy"> I assume that the problem still exist.

    As stated earlier in this post I made a bug report and Ashley answered the following.

    [quote:18u42xvi]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.

    And again unless this have been fixed without me knowing I don't think it have been solved.

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