- Home /
Pixel Perfect
Hello everybody, hope you're having a nice day :).
I was attempting to place tiles on the editor in a perfect manner (meaning precisely next to each other).
In example, assuming we have a 50x50 sprite placed at x:0,y:0 and its 100 pixels to units. One would expect that moving the next tile by x:0.01 would perfectly fit them next to each other, however, the number i actually have to use is something around 0.0405.
I cannot see the correlation.Any ideas suggestions appreciated. Thanks for taking the time : )
If your sprite is really 50 x 50 and it is 100 pixels to the unit, then I would expect your sprite to be 50/100 = 0.5 units on a side. I would expect that the distance to move would 0.5 units. These are world units, not pixels. Neither your 0.01 nor your 0.0405 make sense make sense to me.
Thank you, i suppose the answer i was looking for was the pixelsammount/pixels to units thing. Was facing he ol' you dont know what you dont know problem.
Is there a way to speed up the process ins$$anonymous$$d of doing everything manually however? Tiling 400 sprites by hand and calculations is a somewhat tedious and error prone. ( Im thinking a snap to grid function or something similar)
Thanks a bunch for helping out. Have a great day :)
Answer by Ed unity · Mar 14, 2014 at 03:08 PM
This may be of use to you. Sprite.bounds
(http://docs.unity3d.com/Documentation/ScriptReference/Sprite-bounds.html) (http://docs.unity3d.com/Documentation/ScriptReference/Bounds.html)
The next tile would be the distance between the min.x and the max.x or the min.y and the max.y, depending on which direction you are trying to tile.
That helps as i need to tile a few sprites through program$$anonymous$$g as well. However im mostly interested in how to tile things through the editor in a perfect manner since im mostly looking at static level design. Thanks a lot :)
Answer by Cognitive Dissonance · Mar 15, 2014 at 11:17 AM
To attempt to answer my own question here's an idea derived from what people have answered so far. What if i created an object that holds empty children objects spaced in fixed x/y distances through code and use that as an empty grid that will be populated by the sprites im using as tiles.
Thats just a workaround to the fact that the editor does not have a fast way of placing tiles perfectly next to each other. Does that sound completely retarded :P? Thank you everyone
Your answer
Follow this Question
Related Questions
How can I make a 2d sprite shoot the direction player is facing? 2 Answers
Is there another way of making a Top-Down-2D Map other than generating hundreds of Spriterenderes? 1 Answer
[2D] - Moving the child moves the parent <-- Unwanted behavior 1 Answer
Gaps sometimes appearing between 2D sprites 14 Answers
Simultaneous Animation for an Object 0 Answers