logo hyperPad Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Login

    Pathfinding

    Scheduled Pinned Locked Moved
    General Discussion
    6
    11
    463
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • bosswaveB
      bosswave
      last edited by

      Anyone know of an efficient way to integrate pathfinding in a top-down game? It’s been my biggest roadblock in a couple of projects I’ve tried to create lol. Thanks!

      MelideM 1 Reply Last reply Reply Quote 1
      • MelideM
        Melide @bosswave
        last edited by

        @bosswave I've been searching for that too, couldn't find something simple enough. I saw a project of RobinsonX with a path finder systems, but I don't know if it would fit in all games ^^"

        1 Reply Last reply Reply Quote 0
        • RobinsonXR
          RobinsonX
          last edited by

          I recently created a project that involves pathfinding and it works PERFECTLY! (Not the hyperPad one)

          Unfortunately, it has been written in another language though. BUT, I can explain it.

          1 Reply Last reply Reply Quote 1
          • RobinsonXR
            RobinsonX
            last edited by RobinsonX

            Here is the URL for a simulation of it. (Yes, it involves real-world code.)

            https://py3.codeskulptor.org/#user305_LsWXuY7iAj_7.py

            You can observe what is happening. (Works best on Computers)

            1 Reply Last reply Reply Quote 1
            • RobinsonXR
              RobinsonX
              last edited by

              If I can find any time, I can update my path-finding project in hyperPad. (it's outdated)

              1 Reply Last reply Reply Quote 1
              • RobinsonXR
                RobinsonX
                last edited by RobinsonX

                Alright, I'll try to explain it. (Sorry if this is too much.)

                (Okay, it is too much...)

                Here's a "simple" tutorial.

                1. Have a grid of solid blocks and non-solid blocks.
                2. Let Point A be the starting point and Point B be the destination.
                3. When you want to find a path, perform these execution in order:
                • We will have blocks spreading from Point B. Let Growth Block be a function. Growth Block checks all of its side (up, right, bottom, left) and places a Growth Block for each adjacent non-solid block IF it has not been occupied previously with a Growth Block. After that, it sets a value, let's call it D, in it's place and whatever Growth Blocks it had just summon will set a value of D + 1 instead of D alone. So the D value from the destination should be smaller than the values further from it and vice versa.
                • Starting from Point B, have blocks spread from it. Point B executes a Growth Block in it's place. D should be initially set to 0, but any number would theoretically work. Notice that Growth Block starts a chain reaction where a single block clones into more blocks and covers the whole grid.
                • After the Growth Block has stopped executing, or when the spreading stops, and the starting point has not come in contact with any growth block, then there is no possible path.
                • Otherwise, if the starting point has come contact with Growth Block, then there is at least one possible path.

                — We are only just NOW finding a path —

                • From the starting point, trace a path from the adjacent D values given. Let's have an object, calling it Bob. You can do this by checking the current D value where Bob is.
                • Bob will check the surrounding blocks and will move in the direction where D is less than the D value at Bob. In other words, Bob is moving towards blocks with smaller D values.
                • Bob will repeat this process of looking and moving until the destination has been met.
                1. After a path has been found, you can make whatever character or object follow that path. The path that Bob took can be recorded in an array, a list of directions telling how to get to the destination.
                2. If for some reason, the environment changes, like having a block added or removed, the process shall be repeated. (Or not, it depends on the situation.)
                1 Reply Last reply Reply Quote 1
                • RobinsonXR
                  RobinsonX
                  last edited by

                  2A218FCF-B54A-45BA-BD52-75AD9F66D936.png

                  This is what you should see. (It won't let me place blocks on Mobile.)
                  https://py3.codeskulptor.org/#user305_LsWXuY7iAj_7.py

                  SIRD4SHS 1 Reply Last reply Reply Quote 1
                  • SIRD4SHS
                    SIRD4SH @RobinsonX
                    last edited by SIRD4SH

                    @RobinsonX that... actually helps a lot. Thanks!

                    Now let’s just see if I can replicate this lol.

                    Edit: sorry, I keep forgetting to change the account on my phone.

                    SplitMindGamingS 1 Reply Last reply Reply Quote 0
                    • SplitMindGamingS
                      SplitMindGaming @SIRD4SH
                      last edited by

                      Hyperpad writes to cocos2d which actually has a bunch of tutorials on pathfinding. Im pretty sure it can be possible with hyperpad if new behaviors are introduced to support it.

                      1 Reply Last reply Reply Quote 0
                      • MurtazaM
                        Murtaza Admin
                        last edited by

                        We actually have a tutorial on a basic path finding system
                        https://hyperpad.zendesk.com/hc/en-us/articles/360031030412-Grid-based-Path-Finding

                        bosswaveB 1 Reply Last reply Reply Quote 1
                        • bosswaveB
                          bosswave @Murtaza
                          last edited by

                          @Murtaza thanks, I’ll definitely take a look at it!

                          1 Reply Last reply Reply Quote 0
                          • First post
                            Last post