Pathfinding Issues with Increased Timescale

0 favourites
  • 7 posts
From the Asset Store
Units do not overlap each other and use different ways if there are several free ways.
  • Hello Ashley, I'm making a new thread about this because the other thread (linked below) is older.

    Old Thread

    construct.net/en/forum/construct-2/how-do-i-18/pathfinding-behavior-handle-138787

    Sorry if I'm doing this wrong I've never posted around here. I figured I was alone on this or it was something with my code, but there does seem to be a problem with Timescale and Pathfinding.

    In short its the same problem the previous user had, if you increase the timescale objects seem to get stuck or in my case go in small circles endlessly.

    In my case I'm trying to simulate a speed up for sleeping, so while the player is asleep other things still need to happen, mostly NPCs moving around and such. Since I don't want them to wait forever I currently have the timescale set to 50. I've observed characters walking around during sped up time and it isn't entirely consistent. Sometimes they do fine and other times they just glitch out at seemingly random spots and go in circles. Sometimes they find a way out of their glitch and continue on but its very much a problem. I can also confirm that watching NPCs walk around at normal speed in the game they never have issues.

    Another note is that I had the timescale going at 100 times speed originally but the problem basically happened all the time so I dropped it to 50 and thought it had been solved.

    Personally, I get what you are saying, based on how events are run, at least from what I understand, everything should still go in order just a lot faster. It doesn't really make sense that speeding up the timescale would break it. In any case if you have any insight or fix for this I would appreciate it, thanks.

  • As I understand, the problem is that at x50 speed pathfinding objects are moving too fast and sometimes may run into obstacles, get stuck, miss target position etc. I believe there is a simple solution to this:

    There may still be other issues - NPCs may trigger collision events when moving at high speed, may become destroyed if they have Destroy Outside Layout behavior etc.. You can temporary disable some events/behaviors when the time scale is set to 50.

  • It's always easier to help with an example project. Without one, I can only say it sounds like your timescale is far, far too high - 50x or 100x are both extreme values that the engine is not designed to handle. So, don't do that.

  • Thanks for the quick replies. As for dop2000's suggestion, I think that would work if the problem was it stopping in the right place, the issue I'm having is on the way to the end of the path the sprite bugs out. Although I do think that logic would work for problems at the end of the path.

    Ashley, thank you again, I'm sure you are busy with far more important things. It's good to know that you can't increase the timescale that much. I never read anything about a limit on timescale so I assumed it could handle anything, which in hindsight was dumb of me. In any case I made a bug thread out of this issue because after I made this I experimented more and figured if it really was a problem I should report it. That bug thread that I made did link a capx file with an example, I'll give the link below. I don't really expect a fix since like you said the engine isn't meant to handle that speed but in case you wanted to see its below, thanks again.

    drive.google.com/open

  • It works fine if you set Diagonals:enabled in pathfinding properties. But of course, following the NPC with a camera at 50x speed is not a good idea.

  • It's not sensible to use timescale to fast-forward the game because:

    - it will result in too large steps per tick for any of the game logic to work correctly

    - even if the engine did additional steps to compensate, running at 100x speed will require 100x the system resources - so you will hit the system hard locking the CPU on maximum usage, and likely not get close to 100x speed as a result. (e.g. if your game uses 10% cpu, this approach could only let you speed up to 10x before you run out of CPU time to go any faster)

    The solution, as with most things in games, is to fake it. Just use 'set position' or use some other kind of effect to advance the game faster. The user likely cannot actually follow what's happening at 100x speed anyway, so you just need to make it look convincing while moving the player far ahead enough to save them time.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Alright, since increasing the timescale to such a high amount breaks pathfinding I had to think up another solution. I've gotten a lot of help from people on these forums so I figure its my turn to pitch in. In case anyone in the future needs it there is a capx linked here that simulates pathfinding when the timescale is sped up.

    Fair warning it doesn't really look pretty in game so if a player is going to need to see this happening it probably won't look good. The capx has more details and notes but basically what it does is calculates a path and then uses the nodes that are created to calculate distance between those points. Then based on the objects pathfinding speed the object sets to position to each node in order via a timer. Hopefully this helps anyone else having this oddly specific problem.

    drive.google.com/file/d/12u4MBbLXb9iQ7eBEva6bNPXthicHSXmB/view

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