- Home /
Sprite relative position/scale problem with orthographic camera
I tried to render tiles and other stuff from script and discovered the next problem that I cannot fix: relative position & size of the sprites on the screen are correct only with precise value of Camera.size.
A few examples:
Camera.size = 5. Almost correct. No gaps between tiles.
Camera.size = 7. Incorrect. Tiles are on the same positions but they are smaller, so there are big gaps between tiles.
My low-level code for rendering:
sprite = Sprite.Create(texture, rectInTexture, new Vector2(.5f, .5f));
...
sprite.transform.position = Camera.main.ScreenToWorldPoint(new Vector3(p.x, p.y, 0f);
...
sprite.transform.localScale = new Vector3(scale.x, scale.y, 1f);
So I want to figure out how to make so that different values of orthographic size would not change the relative position and scale of sprites.
Thanks in advance.
If you are creating the sprite reltive with screentoworldpoint function, of course it will make be in diferent world positions dependi g on the camera..
Use another way to create them...
Your answer
Follow this Question
Related Questions
Set camera to specify x,y in pixels? 2d 0 Answers
2D Camera Question: Pixel Perfect W/O Cutting Bottom Edges 1 Answer
Finding the right ortho size to fill the screen with an object 1 Answer
2D Orthographic matching proportions to screen resolution 1 Answer
Dynamic shadows in orthographic camera. 2 Answers