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

    Grid based placement

    Scheduled Pinned Locked Moved
    Help and Support
    4
    8
    381
    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.
    • GadgetkkG
      Gadgetkk
      last edited by

      Hi everyone,

      I’m new here and looking for some assistance... I’m making a top down game that requires grid based drag and drop and grid based item placement (think similar to the pc game factories and thousands of others, that’s just the one that come to mind for this).

      Is that do able? Any have an example I can look at or point me in the right direction?

      Thanks in advance.

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

        This requires math.

        You take the inputs of the position (x and y) and perform modulus with a number, the number will be how big each block will be in the grid (In meters), we will call this number x. Subtract the original inputs by the corresponding outputs and then add half of x to both outputs from the modulus.

        The outputs of the sum will be the fixed outputs of the new coordinate. If you want me to do it for you, or if you want more help, just tell me. :)

        1 Reply Last reply Reply Quote 0
        • GadgetkkG
          Gadgetkk
          last edited by

          I will see what I can do with that info. If I’m still struggling I will back.

          Side question... how does a meter measure on the screen.

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

            @gadgetkk
            A meter is 32 pixels. But you can change this when creating a new project or in the global properties of the project. It is referred as the PTM ratio. (Pixel to Meter)

            1 Reply Last reply Reply Quote 0
            • GadgetkkG
              Gadgetkk
              last edited by

              Ok here is what I’m trying...

              While touching > get position
              Modulus position_x by 1
              Modulus position_y by 1
              Sub position_x minus final mod value
              Sub position_y minus final mod value
              Move to point X result Y result

              And it doesn’t move at all.

              Clue #2 please.

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

                Try a larger number, because 1 is too small. The number represents how big each block in the grid will be. You're basically having each block being 1 meter wide.

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

                  @Gadgetkk Well, actually, you can use any number you want. I just found out that you need to use world coordinates in the While Touching behavior. :)

                  I've made an example that you can try out! I labeled all the behaviors so it can be easily understood, they are located in the large white box in the scene. Open the link in safari and then you can press "open in hyperPad".

                  http://bit.ly/2ZVr9Il

                  1 Reply Last reply Reply Quote 0
                  • Aidan_FireA
                    Aidan_Fire
                    last edited by

                    I uploaded an example of this to the hub a looooong time ago, wonder if it still works.

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