[Solved] Avoid obstacles without pathfinding ?

0 favourites
  • 9 posts
From the Asset Store
In this template the music plays without looping in your game
  • Hey guys!

    Is there any way to avoid obstacles without to use a pathfinding behavior?

    I want to move each time the player on Touch.X / Touch.Y

    So when player is moving to X,Y position to avoid all obstacles on his way.

    Any help, ideas? Thanks!

  • Full answer: https://www.red3d.com/cwr/boids/

    Simple answer: Have each obstacle exert a force vector proportional to the distance away from the object, away from the object.

    Edit: If you have long straight objects like walls, pathfinding is generally the better solution...

    I've also seen SAT used to have objects slide off and around each other http://www.dyn4j.org/2010/01/sat/

  • I know pathfinding is the best solution but there is a reason no use pathfinding behavior in this example.

    I check the links but sorry, if not see at action with a capx example i don't understand how to programming.

    Maybe it's simple without pathfinding but maybe not.

    Sorry but it's too complex for me, that's why i ask for help.

    By the way, thanks for your reply.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • What is the reason not to use pathfinding behavior?

    Another option would be to create a custom pathfinding system, which could possibly be simpler than boids or SAT depending on how flexible you want it to be.

  • The reason is personal, i build a project and pathfinding on what i work no working 100%. Just i need to know a better/different solution. I think can exist, no?

    When you say "custom pathfinding" you mean to create something with sprites? A fake path?

  • Fake path is what I was thinking. Just a quick idea, I haven't tried this, but if your layouts are generally going to be similar to your example it should work...

    You're going to spawn four invisible helper objects at each wall object , offset at each corner. Whenever you select a destination, your player will pick the nearest helper object that exists between player and destination, and move there. When it arrives, repeat for the next closest helper object between player and destination (the ones that have been passed are no longer considered). Continue until no more helper sprites exist between player and destination. This should get you a very rudimentary pathfinding system.

    There are many situations it might not be ideal though...

  • I understand, thanks again.

  • Actually you can do a "PUSH" with add 1 simple event: https://www.dropbox.com/s/elew687p4kdy9 ... .capx?dl=0

  • alextro

    You 're the best bro!

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