Grid based placement
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.
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. :)
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.
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)
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.
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.
@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".
Aidan Oxley last edited by
I uploaded an example of this to the hub a looooong time ago, wonder if it still works.