# Understanding world units/unity units and "Scale"

Discussion in 'Getting Started' started by Quinnje012, Apr 18, 2016.

1. ### Quinnje012

Joined:
Nov 30, 2015
Posts:
7
Hey guys,

I was watching the roll a ball tutorial and everything was going really well, but on the "setting up the play area" tutorial I got caught off guard by presenter just automatically telling me to make the east wall a scale of x = 0.5 y = 2 and z = 20.

Now I realize that these videos were made and edited, but I wanted to know they came up with those numbers? Did they guess and check before releasing the finial video?

Did they look at the grid lines for the "plane" game object and compare it to the cube size and just do quick multiplication?

or does the plane having a scale of x =2, y = 1, and z = 2 tell me what I need to know? and I am just missing a key concept?

I feel like there should be a way to exactly figure out what the proper size of objects should be without counting squares or guess and check work...but I am not seeing the connection between the scale for the "ground" plane and "wall" cube.

If anyone has some insight on this that they are willing to share it would be greatly appreciated. In my research I found that 1unit is = 1meter...but this doesn't really help me.

http://unity3d.com/learn/tutorials/projects/roll-a-ball/setting-up-the-play-area?playlist=17141

2. ### JoeStrout

Joined:
Jan 14, 2011
Posts:
9,859
I think you're way over thinking it. They chose those sizes because they made the wall look good and fit the area they were trying to make. That's all there is to it. I'm sure when they were prototyping, before making the video, they used the scale tool and dragged it around and experimented a bit until they found what they wanted, then they rounded the numbers and wrote 'em down.

In real life, you just experiment until you get what you like, and then round if you prefer round numbers.

And, 1 unit is = 1 meter only if you decide it is so. You could also decide 1 unit = 1 cm, or 1 inch, or 1 mile... it really doesn't matter very much (unless you're involving the physics engine, which beginners tend to do way too quickly, when a lot of games don't need the physics engine at all; and even then, you can adjust the constants in the physics engine to match whatever scale you pick). As long as the width of a typical scene in the camera's view is on the order of tens of units, rather than thousands or thousandths of units, you'll be fine.

Kiwasi and Quinnje012 like this.

### Volunteer ModeratorModerator

Joined:
Jul 19, 2006
Posts:
32,401
Use whatever works. One important thing to keep in mind is limited floating point precision, so don't go too big or too small (generally stay <10K units from the origin).

--Eric

Kiwasi and Quinnje012 like this.
4. ### Quinnje012

Joined:
Nov 30, 2015
Posts:
7
Thank you for the input, it feels weird to me that it is a mess around with it until you find that sweet spot...but im not complaing about it either

5. ### Kiwasi

Joined:
Dec 5, 2013
Posts:
16,860
By default physics is set up for one unit to one metre. UI is set up for one unit to one pixel.

But you can use whatever works for your game. Often there is a natural unit that makes sense. Finding the natural unit will often dramatically simplify the math.

For a tile based game use the width of one tile. For a first person game it might be the height of the character. For my little Pond Wars the natural unit was the distance between two water colliders. That tiny little pond is 100 units across.

JoeStrout likes this.
6. ### JoeStrout

Joined:
Jan 14, 2011
Posts:
9,859
Man, that is so true. Over the last month I bought a couple of rougelike/tile engines from the Asset Store. The one I liked the most (seen here) uses this crazy scale where each grid cell is something like 100/32 world-units across. And furthermore, it flipped the Y axis so that if you were at map Y=5, you were actually at Y=-5*100/32 in the world. So I was constantly having to convert between map coordinates and world coordinates, and vice versa.

I've since thrown that out and made my own tile engine, where I instead chose to have 1 cell = 1 unit, and have Y go up in the map, so map coordinates and world coordinates are the same thing. Whole piles of error-prone code instantly vanished in a puff of logic.

(But hey, you can't accuse me of not trying the off-the-shelf solutions before rolling my own, at least in this case!)

### Volunteer ModeratorModerator

Joined:
Jul 19, 2006
Posts:
32,401
SpriteTile has Y go up in the map, and while it's not required that 1 unit = 1 cell, it's recommended. Just sayin.

--Eric

JoeStrout likes this.