0 Favourites

Pathfinding in reverse

  • Hey all,

    I have been playing around with a little tank game in my spare time. I wanted to know how I could make it so that when a tank finds a path, if it's quicker to travel backwards instead of rotating all the way around, it does that.

    I've tried a few ways, mainly setting the angle of the tank 180 from where it is and mirroring the sprite before calculating the path, but surprisingly it seems to completely ignore this angle change. Even if I disable pathfinding, change the angle, wait one second, then enable pathfinding and find path it still just carries on as if its angle was never changed.

    So, any ideas? Has anyone been through this before?

  • You could use the car movement behavior in conjunction with the pathfinder behavior. Instead of moving the tank with the pathfinder behavior, just use it to find the path. Then use the car behavior to follow that path, and leave a condition saying that if the next node is closer to the front then go forward, or if closer to the back go backwards.

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • Thanks for the reply, but it's a bit too involved for me (it's just a muck around project for when I need a break from my RPG). I tried doing what you suggested when pathfinding first came out, but it got pretty messy and I never could get it to behave exactly how I wanted.

    If there's no simple way to about-face, I'll just leave it as is I reckon.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic
105 16,954
Magistross's avatar
Magistross
Topic
21 474
YoHoho's avatar
YoHoho
Unread hot topic
0 Favourites
Pathfinding AI
33 2,367
Lordshiva1948's avatar
Lordshiva1948