How do I manage a large sprites with pathfinding ?

0 favourites
  • 3 posts
From the Asset Store
Units do not overlap each other and use different ways if there are several free ways.
  • 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 :

    Thank you very much !

  • 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

  • Try Construct 3

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

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

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