How do I Normal Pathfinding for RTS

Get help using Construct 2

Post » Thu May 18, 2017 6:08 pm

HI! Just searhing for good pathfinding solution without crossing sprites.
Try RTS-template and other method - not working. When i select my units and send it to positions - they crossing each other.
Can any body help with it?
B
9
S
3
G
1
Posts: 8
Reputation: 1,143

Post » Fri May 19, 2017 1:08 am

Making objects avoid each other while using pathfinding is an interesting problem. You can make each object as an obstacle to each other, but this causes a lot of issues on itself - like poor performance - and still they will pile up on top of each other frequently.

I made a nice solution to this, but it might or might not work for you... I used the BOIDS plugin to help.

For each of my "units" I made a "ghost unit" that was the pathfinding guide for the actual unit that the ghost unit is assigned to. I made a 'container' with the unit and the ghost together, and set the ghost to "flock" to the destination using the boids behaviour... then set the actual unit to pathfind to the ghost if it's distance was more than say 10-20 pixels.

In this way, the boids behaviour takes care of the avoidance/steering of the destination and the pathfinding will travel to the ghost/boid.

There are a couple of boids plugins available - I used the old/original one (I found Rex's boids was a little too much for what I needed and the old version worked exactly how I wanted without anything too difficult).

In short it goes a little like this:

[UNIT] ----pathfinding to----> [GHOST] -----flock/boid to-----> [DESTINATION]

I hope this sheds some light on the method.

~Sol
Tired of crappy file hosts that are crappy? Get DROPBOX - https://db.tt/uwjysXJF
Moderator
B
83
S
34
G
40
Posts: 3,032
Reputation: 30,474

Post » Fri May 19, 2017 5:39 am

Wow nice solution! thank you very much!
Did this method has some know bugs? And how units will avoid solid objects?
Do you have some simple capx sample?
B
9
S
3
G
1
Posts: 8
Reputation: 1,143

Post » Fri May 19, 2017 7:15 am

There are no bugs that I am aware of.

I also added Line Of Sight behaviour to the "ghost" objects (because my boids objects are following a moving player) - then if LoS is lost, the "ghosts" position are simply set to the player position - then the boids flocking takes over again to create a nice spread pattern for the pathfinding destination.

If you want to avoid solids accurately, I would also recommend using "custom movement" behaviour on your ghost objects and tell them to push out of solid if they overlap. This will ensure your units will always find a path since the ghost will never trap itself directly inside of a solid.

I do have a capx file, but it's my current prototype/project and is probably way more complicated for showing this method.

If you have trouble getting a good result let me know and I will see what I can do. I start a new job on Monday so my free time is greatly impacted - but I can perhaps share my project with you if you keep it to yourself and don't share :)

~Sol
Tired of crappy file hosts that are crappy? Get DROPBOX - https://db.tt/uwjysXJF
Moderator
B
83
S
34
G
40
Posts: 3,032
Reputation: 30,474

Post » Fri May 19, 2017 8:51 am

send you PM :)
B
9
S
3
G
1
Posts: 8
Reputation: 1,143

Post » Fri May 19, 2017 4:36 pm

SoldjahBoy wrote:There are no bugs that I am aware of.

I also added Line Of Sight behaviour to the "ghost" objects (because my boids objects are following a moving player) - then if LoS is lost, the "ghosts" position are simply set to the player position - then the boids flocking takes over again to create a nice spread pattern for the pathfinding destination.

If you want to avoid solids accurately, I would also recommend using "custom movement" behaviour on your ghost objects and tell them to push out of solid if they overlap. This will ensure your units will always find a path since the ghost will never trap itself directly inside of a solid.

I do have a capx file, but it's my current prototype/project and is probably way more complicated for showing this method.

If you have trouble getting a good result let me know and I will see what I can do. I start a new job on Monday so my free time is greatly impacted - but I can perhaps share my project with you if you keep it to yourself and don't share :)

~Sol

Your mail box is Full
can you send me simple capx example :) want to look how it will be work
B
9
S
3
G
1
Posts: 8
Reputation: 1,143

Post » Tue May 23, 2017 4:00 am

Hey sorry for the late reply, I've been busy with my new job... I can see what I can put together but it may not be until the weekend. :)

~Sol
Tired of crappy file hosts that are crappy? Get DROPBOX - https://db.tt/uwjysXJF
Moderator
B
83
S
34
G
40
Posts: 3,032
Reputation: 30,474

Post » Mon May 29, 2017 5:36 am

SoldjahBoy wrote:Hey sorry for the late reply, I've been busy with my new job... I can see what I can put together but it may not be until the weekend. :)

~Sol

I check your sample! Wow Its so complicated for me. :) Try to learn something new with your sample.Thanks !
don't know about dir pos. Cool method. By the way I have som Super formula to use dirrection with just one simple string its convert angle to animation number.
I use this ceil(8*(1+Tank_basePl.Pathfinding.MovingAngle/360)-0.5)%8 find this in forum
its give 8 direction of sprite - if you change 8 to 16 dir - it will be 16 dir direction of sprite angle.

Again can't send you pm :(
B
9
S
3
G
1
Posts: 8
Reputation: 1,143

Post » Mon May 29, 2017 6:20 am

Weird, my PM box isn't full so I'm not sure why you can't send one :/

Let me know if you need help understanding the project - it is quite complicated as you said, but I think mainly the part you are looking for is the events that I mentioned in my message :)

~Sol
Tired of crappy file hosts that are crappy? Get DROPBOX - https://db.tt/uwjysXJF
Moderator
B
83
S
34
G
40
Posts: 3,032
Reputation: 30,474


Return to How do I....?

Who is online

Users browsing this forum: Fradno, MathNook and 37 guests