Hello Guest

Author Topic: Tile XY Position not precise  (Read 4279 times)

Phuzz

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 6
    • View Profile
Tile XY Position not precise
« on: September 01, 2015, 10:21:04 am »
Hello,

I have my 32x32 tiles with the Tilemap partition size X and Y also set to 32, painting the tiles and everything seems ok and visually correct, I would imagine tiles would be at coordinates (0,0)(0,16)(0,32) and so on, but when I get the positions of the tiles the following happens:

X-Y
0-0
0-17.77778
0-35.55556
0-53.33334
0-71.11111
0-88.88889
0-106.6667
0-124.4445
0-142.2222
0-160

That makes every 10th tile set at 160, even though it should be every 8th so I can get my grid based game precise.

My tiles are perfectly 32x32

Am I missing something?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Tile XY Position not precise
« Reply #1 on: September 01, 2015, 10:50:41 am »
What is your pixels per meter / ortho size set to on the sprite collection? It will only match the size of the pixels exactly if it was set to 1PPM

Phuzz

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Tile XY Position not precise [Solved]
« Reply #2 on: September 01, 2015, 11:14:09 am »
Thank you, setting 1ppm on sprite collection settings did it for me  :)

LaserDinosaur

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 38
    • View Profile
Re: Tile XY Position not precise
« Reply #3 on: September 02, 2015, 06:23:07 pm »
It's usually a good idea to set your PPM to 100, that plays nicer with Unity's physics systems. In Unity the default is 1 unit = 1 meter, which then works out to be 100 pixels per meter. That gives the physics system a bit more of a normalized world scale. At 1 pixel per meter, a sprite that is 32 pixels high is now 32 meters tall, which will create some large scales that the default settings don't handle too well (eg. Min Penetration, Velocity Threshold).

If you do use a PPM of 100, any time you want to move a unity a certain number of pixels, just divide by 100 (so 32 pixels becomes 0.32f). Also it's not a good idea to change this value half-way through development, it will throw off your layouts quite a bit.

Extra threads on the topic:
http://2dtoolkit.com/forum/index.php/topic,3498.msg20148.html#msg20148
https://www.reddit.com/r/Unity2D/comments/2aqg9d/what_pixel_per_meter_should_i_develop_the_game_at/