Pathfinding obstacle affecting other objects

Get help using Construct 2

Post » Fri Feb 03, 2017 2:23 pm

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?
B
47
S
17
G
82
Posts: 2,230
Reputation: 48,607

Post » Fri Feb 03, 2017 3:13 pm

plinkie wrote: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
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,848

Post » Fri Feb 03, 2017 5:32 pm

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.
B
47
S
17
G
82
Posts: 2,230
Reputation: 48,607

Post » Sat Feb 04, 2017 2:52 am

plinkie wrote: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 :D
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,848

Post » Sat Feb 04, 2017 11:21 am

@nimos100

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

Ty.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Sat Feb 04, 2017 2:45 pm

99Instances2Go wrote:@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.
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,848

Post » Sat Feb 04, 2017 4:29 pm

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)
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Sat Feb 04, 2017 5:33 pm

99Instances2Go wrote: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.
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,848

Post » Sat Feb 04, 2017 6:34 pm

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

Whatever.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Sun Feb 05, 2017 4:38 pm

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)
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 14 guests