[Path finding] No slow down?

Get help using Construct 2

Post » Fri Sep 26, 2014 7:36 pm

Anyone using the path finding behaviour know if its possible to make it work without stopping the objects as it changes path?

Normally when you tell something to go a certain path and its moving and then changes to a new path the object stops, rotate and then moves again.

What im looking for is to make an object take a smooth path to the new location, so it takes the speed and direction of the object into account as its generating the new path.

Know its a long shot :D but maybe someone found a solution or workaround.

Cheers
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,838

Post » Fri Sep 26, 2014 7:58 pm

I never tried this but just an idea/theory you could try, make an invisible object that is finding a path and the object will spawn "checkpoint" which the actual character will move to the min(iid). If the invisible object stop,rotate,return same path, make it destroy the checkpoint on collision. I think this will work if the invisible object move fast enough. Probably works in confined path only, not sure if it is good for open space.

Try it, see what happen and let me know :D
B
28
S
8
G
4
Posts: 553
Reputation: 4,924

Post » Fri Sep 26, 2014 8:34 pm

Unfortunately such solution for my game wouldn't work, as it would increase the number of objects to something that would hurt performance quite a bit i think. Or it just wouldn't be able to calculate it fast enough to avoid stopping the ships anyway i think.

Also it is ofc difficult to know as i haven't explained what and how im gonna use it :D. But im making a space simulator game and as you change solar system all units, objects etc that belong to that system gets loaded. And i was using the path finding for when units are moving through galaxies, solar systems and so on when they are in the active system that the player is looking at, but the problem occurs as the player is able to switch to any solar system or galaxy they like, But that doesn't prevent ships from still travelling. So all player ships in the game have two systems for moving, one for direct control as the player can move to anywhere in a solar system that they like, but also when the player have given some units order to travel somewhere, they need to be able to go through jump gates and do whatever they are ordered to do. And whenever these units are not in the active system that the player looks at, another movement system takes over, that makes sure that these ships still keep moving, so when the player switches back to the system all the ships have continued moving to where they were heading or jumped to other solar systems etc. So the new distance and where to place the ships in the system is calculated based on the second movement system. It probably sounds confusing :D But when the player switches back the path finding takes over again. But as it need to recalculate the path the ship, they some times stops for a short while before moving, and it just seems weird.

But if i could make it so the ships continued moving as the new path was found the problem would be solved. I do however get some better results by disable and enable the path finding, but its a bit buggy at the moment.

But you suggestion gave me another idea that i might try to solve it :D
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,838

Post » Sat Sep 27, 2014 2:54 pm

The problem is pathfinding can take a moment to complete, in which time the object could move to a new cell, requiring a new path to be found from a new starting location... during which time the object could move to a new cell again, and so on.

If it's noticable, you probably need a larger cell size so paths are quicker to calculate.
Scirra Founder
B
395
S
232
G
88
Posts: 24,368
Reputation: 193,756

Post » Sat Sep 27, 2014 3:11 pm

Thanks for the reply.

The problem is/was that as i increased the cell size the precision went with it as well, so units would not go to the correct coordinate but just somewhere near it, and that looked weird as the scale of objects are not that big, it needs to be somewhat precise.

The idea or hope :) was that somehow it was possible to make the path finding calculate based on the speed and direction of the object, where the actually path finding would start. So even if it changed cell it wouldn't have reached the point from where the changes would take place. But as it did the new path found from that location would take over. But as i said i knew it was a long shot, and not even sure that A* is capable or used for such type of prediction movement.

But anyway i remade how it works so it doesn't rely on path finding in those cases anymore and it works as it should now.

However it uses a every tick movement system now, and since there might be a lot of units presents on the map at the same time, i was wondering if there are any performance hit from doing it that way compared to for instant using one of the other movement behaviours or will it be the same in the end?
The movement is pretty simple a unit have a direction and move "unit_speed * dt" in that direction, so its not more complicated than that. But read somewhere in another post that someone said to stay away from every ticks. Which i agree with in most cases as its not needed, but in this case i need that or one of the behaviours, but would prefer not to discover later on that doing it with every tick will serious limit the amount of units (Im not talking 1000s, but around 30-50 max) which ofc is not a lot, but as the rest of the units are calculated offscreen there might be 1000-1500 in total, so no need to make it worse than it need to be :D
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,838


Return to How do I....?

Who is online

Users browsing this forum: brunopalermo, David181, dop2000, mekonbekon, namaewayukidesu, senecaa, Yahoo [Bot] and 13 guests