How do I Normal Pathfinding for RTS

0 favourites
  • 9 posts
From the Asset Store
Finding the shortest path through the cells based on the A-star algorithm
  • 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?

  • 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

  • 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?

  • 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

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • send you PM

  • 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

  • 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

  • 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

  • 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

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