Pathfinding obstacle affecting other objects

0 favourites
  • 12 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • I'm having an issue where I have two objects which I should add were cloned from each other originally. One, object, 'civilian', on created has a 'tile' pathfinding obstacle added. For some reason, the other separate object, 'pawn', is affected by this. When a civilian is created, the pawn suddenly starts detecting the 'tile' as an obstacle as well. Obviously this could be difficult to determine without any events shared but has anyone come across this before where they found a reason behind it?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I'm having an issue where I have two objects which I should add were cloned from each other originally. One, object, 'civilian', on created has a 'tile' pathfinding obstacle added. For some reason, the other separate object, 'pawn', is affected by this. When a civilian is created, the pawn suddenly starts detecting the 'tile' as an obstacle as well. Obviously this could be difficult to determine without any events shared but has anyone come across this before where they found a reason behind it?

    My guess is that you are experiencing what is discussed in this thread:

    https://www.scirra.com/forum/suggestion-is-it-feasible-to-have-2-preset-obstacle-maps_t186546

  • You're right but I think I might've found a fix? You suggested it was limitation of C2 which seems feasible but I tried a different pathfinding behaviour for each object now (different names) and it appears to be creating two different object maps and working. Have you tried this before? May be an acceptable workaround.

  • You're right but I think I might've found a fix? You suggested it was limitation of C2 which seems feasible but I tried a different pathfinding behaviour for each object now (different names) and it appears to be creating two different object maps and working. Have you tried this before? May be an acceptable workaround.

    I believe i have tried about anything I can think of to make a workaround for it, but weren't able to do it. From the tests I did it seems to not matter what you do, there is one obstacle map and all objects using path finding will share it. However it have been some time since I have looked at it as I assume it haven't been fixed based on Ashley explanation of how it is designed. But feel free to add a Capx as I would like to see if you might have tricked it somehow

  • nimos100

    Explain 2 me why the capx that i posted in the topic that you linked to is working flawless.

    Ty.

  • nimos100

    Explain 2 me why the capx that i posted in the topic that you linked to is working flawless.

    Ty.

    Its actually quite interesting because at first glance your CAPX seems to work fine, and it took me a while to figure out why, because even if I copy/pasted yours, mine still weren't working. But looking further into it, it turns out that it have nothing to do with how you programmed it. You don't need all the regenerate obstacle map, global variables or trigger once, you could have made it straight up like this:

    On mouse left click -> A.findPath

    On path found -> A.movealongpath

    etc. etc.

    For some strange reason it seems that the cell size of the objects is very important, much more than I thought. Because the reason yours works or appears to work, which of course it does to some degree, is because the obstacle map is linked to the cell size of the sprite. You can test this very simply by changing the Cell size of object A to be the same as B (32). When you move A it will work correctly, however when you move object B it will ignore the obstacle map that you told it to and start using object A instead, which seems illogic why it should do that, but interesting and good to know non the less.

    So your example might actually have help me at least, to find a semi acceptable workaround for the path finding, because you might be able to get at least somewhat unique path finding simply by using different cell sizes to simulate different types of object, lets say a (Ship or Car). So you could give the Ship a cell size of 32 and the Cars a cell size of 31 and in theory from what I can see it should work, but whether that will give a lot of bugs later on with weird movement etc. I don't really know, but definitely worth testing out at some point in a serious game.

  • Uuhhh nope. I do need to recalculate the maps. Because, you obvious did not notice, right/left click is changing the tilemap. And there for the obstacle map.

    Again, it just waits till the obstacle map is ready before initiating a 'find path'.

    (although i have to admit that i cheated on the concept: hard to press right/left click on the same time)

  • Uuhhh nope. I do need to recalculate the maps. Because, you obvious did not notice, right/left click is changing the tilemap. And there for the obstacle map.

    Again, it just waits till the obstacle map is ready before initiating a 'find path'.

    (although i have to admit that i cheated on the concept: hard to press right/left click on the same time)

    Fair enough you have to use the regenerate obstacle map if you make changes to the map for whatever reason. But I assumed that you only changed the tilemaps to mark where the player clicked as you used fixed the targets for the sprites to path find to anyway. But its not really important regarding the obstacle maps and how they work I think.

  • But its not really important regarding the obstacle maps and how they work I think.

    Whatever.

  • Again. According your comments, this should be totally not possible.

    https://www.dropbox.com/s/79jl1kgt0xfjc ... .capx?dl=0

    Yet, i have 8 instances of the same objects & 1 extra object with differed obstacle maps, finding a legit path.

    They, again, just wait for the obstacle map to be build.

    (not that i like the paths at all)

  • Nice, I thought it was possible. For some reason when I added an obstacle for one object it was making it an obstacle for another object. I think it was the point at which i was rebuilding the obstacle map that was the problem in the end.

  • Again. According your comments, this should be totally not possible.

    https://www.dropbox.com/s/79jl1kgt0xfjc ... .capx?dl=0

    Yet, i have 8 instances of the same objects & 1 extra object with differed obstacle maps, finding a legit path.

    They, again, just wait for the obstacle map to be build.

    (not that i like the paths at all)

    Im not sure what this example is showing in regards to the obstacle map issue in C2?

    If this weren't directed at me but the OP, you can just ignore this comment.

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