How do I manage a large sprites with pathfinding ?

Get help using Construct 2

Post » Thu Oct 12, 2017 7:19 am

Hello fellow programmers,

I am having a problem I cannot resolve at the moment.

I am (still) doing a tower defense game, and while I managed to make my pathfinding behavior work more or less properly with small sprites, I have one of my towers that "shoots" a poison cloud that basically "pathfinds" from its spawn location on the path all the way to the beginning of the track.

The pathfinding logic is fine. Everything that is not "the path" has the solid behavior, and the cloud has "solids" as obstacles in its logic. I used events to see which cells were obstacles and which ones weren't, and everything looks good.

Here is the problem :

When you go in the Construct 2 pathfinding example (the one with the green arrow), the sprite is quite small, and it certainly does not collide with obstacles. BUT try to make the sprite bigger, say 60*60, and you can see the arrow overlapping with obstacles all over the place.

Hence Two questions :

-What does defines the object's "hit box" when pathfinding ? (the actual hit box, small or big doesn't seem to matter, I tested it)
-How do I make a medium sized sprite, about 60*60 not overlap with cells marked as obstacles ?

Here is a visual representation of what im saying, in the Construct 2 example :

Image

Thank you very much !
B
12
S
4
G
1
Posts: 39
Reputation: 1,378

Post » Thu Oct 12, 2017 8:51 am

Yeah the hitbox is irrelevant, it's the 'cell border' that has an effect. Take a look here: https://www.scirra.com/manual/154/pathfinding
B
47
S
17
G
81
Posts: 2,224
Reputation: 48,095

Post » Thu Oct 12, 2017 4:31 pm

Yeah I understand that part, and I understand cell border helps, but when dealing with medium sized sprites, the problem with pathfinding is that the outer part of the sprite still heavily overlaps with cells marked as "obstacle".

furthermore , let's say you are trying to pathfind an object from the center of your screen to the upper let part of it, with a set path being only horizontal and vertical lines, the sprite will automatically hug the left part of your path instead of staying in the middle... Which, you guessed it, makes the sprite overlap even more.

Is there not a way to make the sprite stay in the middle of the path while pathing ?
B
12
S
4
G
1
Posts: 39
Reputation: 1,378


Return to How do I....?

Who is online

Users browsing this forum: blackhornet and 25 guests