RTS template pathfinding :(

Discussion and feedback on Construct 2

Post » Sat Jun 07, 2014 5:43 pm

Hello,

I see that pathfinding... (or more likely units moving along path) still suffer from terrible overlaping.
If you move them several times (a bit further path), they eventally all end up on top of each other... :(
I persume that this is never going to be fixed... :(
(maybe its not even considered as an issue)?
Does anybody know, is there some sucessfull solution for this?

Thank you!
B
29
S
11
G
2
Posts: 691
Reputation: 5,157

Post » Sun Jun 08, 2014 6:22 am

If you give the units physics behavior, they will collide with each other and not overlap. Just set the world gravity to 0 else they fall off your layout. ;)

I believe @Arima has done it.

Alternately, I've done it using Rex's SolidPushOut plugin: https://dl.dropboxusercontent.com/u/577 ... solid.html

Set your unit to that behavior and set them to Solid.

You will have to customize the obstacle to something else rather than Solid, trigger it via on startup etc.

This approach works too and uses very little CPU processing so its fine on mobiles. The only downside is they look like bump cars sometimes, they push out a bit too much. But honestly its just a minor issue, otherwise visually and gameplay wise, its fine.
B
70
S
24
G
19
Posts: 1,757
Reputation: 17,616

Post » Sun Jun 08, 2014 8:24 am

@Silverforce

Thank you for your advices but:
1st solution is not working as one would expect...
They are pushing each other over the solids... then glide, spin etc... lotsa wierd stuff... :(

2nd is not working either... they are solid and they dont move.

any other ideas?
B
29
S
11
G
2
Posts: 691
Reputation: 5,157

Post » Sun Jun 08, 2014 11:10 am

glide and spin can be changed via setting the physics variables in the behavior.

2nd option works fine for me, i opened the default RTS template, add the behavior (after install Rex's plugin first!) and they move but wont ever overlap. They push each other out whenever they contact. You need to change the obstacle in Pathfind behavior to CUSTOM and not DEFAULT to SOLID. Then on start of layout, add an obstacle to your unit. ie. "Wall" or "Barrier" etc.
B
70
S
24
G
19
Posts: 1,757
Reputation: 17,616

Post » Sun Jun 08, 2014 11:56 am

@Silverforce

OK, i am opening template...
added to "firendly bases" pushout solid behavior
nothing happens... they overlap.
then i add regular solid behavior
they are solid now and i cant move them...
i am now changing obstacles in Pathfind behavior to CUSTOM
they can move now but they cant navigate proper path... (they seem to plot a straight line and just stop at obstacle)
and enemy tanks are now crazy going straight through walls (i did not even touch them yet)
and now im kinda lost... :(
B
29
S
11
G
2
Posts: 691
Reputation: 5,157

Post » Sun Jun 08, 2014 12:27 pm

I just added that pushout and solid to Tank1Base directly, without doing it via the Family. Custom obstacle so they move. The walls are set as solid so they do hit the walls and cannot go through it.

Not sure about enemy tanks, i havent look at that RTS code template in detail. But what you want: Pathfind AI to not overlap and bunch units together is possible.

I use it in my own RTS game, some big fights have heaps on each side and they don't overlap.
B
70
S
24
G
19
Posts: 1,757
Reputation: 17,616

Post » Sun Jun 08, 2014 1:00 pm

@Silverforce

let me share what iw done... just select them all and click to move

https://dl.dropboxusercontent.com/u/169 ... B/RTS.capx

Maybe i am doing something wrong?
B
29
S
11
G
2
Posts: 691
Reputation: 5,157

Post » Sun Jun 08, 2014 2:51 pm

This is an extremely complicated problem and even designers of top commercial RTS games struggle with it. There is not a clear, easy solution that works well in all cases. It's something you're going to have to experiment with and come up with something that works reasonably well for your own game.
Scirra Founder
B
399
S
236
G
89
Posts: 24,530
Reputation: 195,402

Post » Wed Jun 11, 2014 1:33 pm

@Ashley
May i make one sugestion?

Can you create one more event in pathfinding behaviour that might get called "path blocked"
where unit would on path that was once was clear and executed but in the meanwhile becomes blocked (by friendly units or maybe new solid obstacles) try to recalculate new path?

thanx.
B
29
S
11
G
2
Posts: 691
Reputation: 5,157

Post » Wed Jun 11, 2014 2:19 pm

@irina - that in itself is a very difficult problem and doesn't necessarily help. If two objects drive in to each other head on, do they both go in to 'path blocked' mode? What if a whole traffic jam or gridlock forms? The whole essence of the problem is really determining that, it doesn't help reduce it much. Also pathfinding by default does not try to avoid any other objects, so recalculating the path will just return the same path it was already on.
Scirra Founder
B
399
S
236
G
89
Posts: 24,530
Reputation: 195,402

Next

Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 6 guests