[SOLVED] Snapping to Grid Problem

Try as I might I cannot get the snap to Grid settings working at all :sweat:. The .32 for the Y axis is the main culprit and how to we come up with that figure of .32 - I know there must be a reason, but, I do a lot of this course late at night or early in the morning, so, I must of missed something important here. Does anyone have a clue as to what I might be doing wrong or what to change to get it working?

Please help!!!

PS - In the meantime I have had to resort to vertex snapping.

When you say it isn’t working, can you clarify?
What is it not doing that you’re expecting it to do?
What is it doing that you’re not expecting it to do?

As a wild guess as to what might be wrong (given your statement about working late or early), are you holding down Ctrl (or Cmd if you’re a Mac user) as you move your bricks?

I figured it out just then - the working early in the morning was the problem :smile:. After dragging in the images I needed to “Snap All axes” so, the images would move properly into the grid - so I could then snap them around the grid. Without that it was just a mess. I missed that one sentence - took a couple of viewings of that part of the video till it clicked as something important.

It was the 0.32 thing that threw me, I still don’t know how we arrived at that figure - it was like he expected us to know and I had no idea! Still don’t :sweat:. I’m not much of a math’s person ask me to do a Juji Gatame or a Sankaku Jime or Kote Gaeshi, I’m your man but working out a math problem, not on your life.

Sorry about that!

0.32 on the y axis explained…

1 world unit set to 128 pixels as per previous lecture
Thats 128 pixels on the x and y
The block sprites are 41 pixels in height

128 / 100 = 1.28 pixels per percent
1.28 x 0.32 = 40.96, rounded = 41 pixels

Hope this helps

@Rob I used to be good at maths and (maybe because it’s early) that’s clear as mud! :laughing: Maybe because you skipped all parts of finding out what % of 128 , 41 is? I’m guessing, as I said, it’s early and your post lost me after the pixels per percent; it just seems to presume knowledge of some numbers and doesn’t explain where they came from.

I got my head around it (especially as I’m defying orders and working with 128x40 - no problems so far, early morning maths aside :grimacing:) by looking at it the following way:

We’ve decided 1 World Unit is 128 pixels - this is a fairly arbitrary decision based on block/paddle width. However our block isn’t a full World Unit high, ie. it’s less than 128 pixels on the y axis.

If we work out how many times the ‘height’ of our block goes into its width, we can then divide the World Unit width of the block by the same number to get the World Unit equivalent of its height.

So, for a 41 height block, you divide width by height (128/41) and get 3.12195122
And then convert to World Units: 1 / 3.12195122 = 0.3203125 which rounds to 0.32

Anyway, glad you managed to get the snap working @Vaughan_MacEgan :thumbsup:

2 Likes

You’re right, I should have probably gone in to more detail, my apologies. I was a little after 1am and I was trying to help before going to bed - lesson learned.

Some of my response was however based on presumed knowledge. The width and height of the blocks had already been given in a previous lecture. Equally the arbitary 128 pixels is explained in a previous lecture also (iPad Air 2048 pixels screen width and research into typically block widths for Arkanoid-esq games).

I divided 128 by 100 as the 0.32 represents a percentage, as with many (but not all) of the ranges in the Unity Inspector, values will vary between 0 and 1. The value of 1.28 will be the same for both the x and y values.

In effect my example is a reverse of yours, but I will concede that it does rely on that previous information being read/known and I should have shown the calculation finding the 0.32 not using it to confirm it’s purpose. I could have for example take the 41 pixel height and divided it by the 1.28, thus arriving back at the 0.32.

Thanks for the feedback.

Thanks greatly to the both of you for going into this calcuation in more detail :sunglasses:. It really is much appreciated!

Warmest Regards.

1 Like

Privacy & Terms