Custom Pathfinding - Less Overhead

This forum is currently in read-only mode.
From the Asset Store
Units do not overlap each other and use different ways if there are several free ways.
  • I am currently working with the RTS pathfinding behavior to try and accomplish a racing line to direct the AI around the tracks of a TD Racer I am working on. I have set up more than 30 points using individual sprites around the track to represent the path and am directing the ai to move from point to point determined by a private variable. The event sheet is getting way out of hand considering I am going to attempt to implement 22 ai opponents. I am thinking before I get to ahead of myself that I might want to think about making this met hod a bit simpler.

    My event sheet is looking something like what you see below.

    Timer is equal to 4000 - aicar01 set 'point1' to 1

    Always(Every Tick)

    +aicar01: Value 'point1' equal to 1 - add waypoint at point1

    - move to point1

    Always(Every Tick)

    +aicar01: Value 'point1' equal to 2 - add waypoint at point2

    - move to point2

    Always(Every Tick)

    +aicar01: Value 'point1' equal to 3 - add waypoint at point3

    - move to point3

    etc...etc...etc... until the ai car equals point 30 and then loops

    to change the value I have set it to change when you overlap each point as to create a loop

    so it looks like this.

    aicar01 overlaps point1 - set point1 to 2

    aicar01 overlaps point2 - set point1 to 3

    aicar01 overlaps point3 - set point1 to 4

    etc...etc...etc...

    As you can see this process becomes very repetitive when having to create each cars pathfinding and I would really like to simplify this. Any suggestions?

  • First I can tell you that having Always is redundant when it's surrounded by other conditions. Secondly I'd recommend making a single waypoint object and giving them each a value dictating which one they are.

    Third, make it so when the waypoint's value equals the car, that a waypoint should be added to it.

    Finally, make it so when the car overlaps a point it sets the car's value to it's value+1

    I think that should do it.

    EDIT: Oh, and if car's value=31, set to 1

  • First I can tell you that having Always is redundant when it's surrounded by other conditions. Secondly I'd recommend making a single waypoint object and giving them each a value dictating which one they are.

    Third, make it so when the waypoint's value equals the car, that a waypoint should be added to it.

    Finally, make it so when the car overlaps a point it sets the car's value to it's value+1

    I think that should do it.

    EDIT: Oh, and if car's value=31, set to 1

    So if I set Always (Every Tick) and then add sub events to it then those events are redundant? If so, that is good to know. Your solution is interesting. I will sit down and try and implement it when I get a chance. Thanks Yarfapet, you saved me a lot of time!

  • Ok, I admit I am a little confused by this, any chance you could be more specific or share an example of how this might look? When you say "add single waypoint and add a variable to define which one they are." this is what confused me.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ok, I admit I am a little confused by this, any chance you could be more specific or share an example of how this might look? When you say "add single waypoint and add a variable to define which one they are." this is what confused me.

    Never mind, I was confused because I noticed that by placing more than one of the same object throughout the layout and renaming one would cause all of them to be renamed to the same thing so I only assumed that if I changed a variable for one then that same variable would change for all of them. My mistake, I didn't realize that you could add a separate variable for each of the same object. Thanks! Works like a charm!

  • No prob. BTW, this just dawned on me now. But if you ever wanted to clean up your code further, you could always put all the aicars in a family and reference the family instead of the individual cars, then you'd only have to write the code once.

    Construct, one heck of a gradual learning process.

  • No prob. BTW, this just dawned on me now. But if you ever wanted to clean up your code further, you could always put all the aicars in a family and reference the family instead of the individual cars, then you'd only have to write the code once.

    Construct, one heck of a gradual learning process.

    Tell me about it! I haven't yet gotten into families and am unfamiliar with there use in Construct as of this moment. Wish there was a quality help file or manual of sorts.

  • Wish there was a quality help file or manual of sorts.

    http://sourceforge.net/apps/mediawiki/c ... e=Families

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