Pathfinding in multiple layers

Just started using Construct 2? Post your questions here

Post » Mon Sep 07, 2015 1:09 pm

The pathfinding page makes no mention of how the Pathfinding behavior handles multiple layers. Does it keep a separate grid for each layer of the game?

If I add two instances of an object with the behavior to different layers with different obstacles, how will they behave?
B
6
S
1
Posts: 14
Reputation: 330

Post » Mon Sep 07, 2015 2:15 pm

I think the layers are just the visual aspect, for having objects displayed above others. Objects can still interact with each other on other layers to my understanding.
B
9
S
3
Posts: 104
Reputation: 1,033

Post » Mon Sep 07, 2015 2:54 pm

I was under the impression that the pathfinding grid would only take the solids in the same layer into account. It would make sense from the way the manual is written that the pathfinding object takes all solids when building the grid. That will complicate things. I need the ability to have seperate pathfinding grids. Think about the different floors of a house, each can have people moving around, each with different object arrangements.

I suppose I could create a different object with the pathfinding behavior for each floor, and give each slightly different pathfinding values so they are tracked separately. The pathing is based on a tilemap, so I could just add the tilemap for each floor as the obstacle for that floors pathfinding behavior. Add each object to the character container and pin the character to it, then just call the object that matches the floor the character is on to move the character with pathfinding specific to that floor. It should work, but will make adding single objects more complicated since there is no action to remove a specific obstacle, I guess I could keep a list of every obstacle for each floor and if one is removed, remove it from the list, wipe the pathfinding obstacles and readd them all on the list. Should be able to get away with only rebuilding the area of the grid that was effected. If its alot of objects then the removing action could start to get expensive.
B
6
S
1
Posts: 14
Reputation: 330


Return to Beginner's Questions

Who is online

Users browsing this forum: JackTYGA and 3 guests