So I've been building my shop for my 2D game for a few days now and it is almost finished. Problem is, when I test it for various resolutions, my coin sprite (next to every price text) disappears and I couldn't figure out why.
I tried to change the sprite's max size but didn't work.
Any idea would be very helpful. Thanks a lot.
Edit: Here are some screenshots for 16:9 and 18:9 resolutions.
16:9 - https://ibb.co/dKQNB4K
18:9 - https://ibb.co/ns2KKgr (No coin sprite visible)
Related
I am working in Unity2D and have a character who can shoot in all directions. The game has mobile controls and the player will choose his shooting direction with a joystick on the right side.After testing I found it rather difficult to correctly determin where the shot is going to land at. To convey this to the player I wanted to add a sort of "shooting line of sight" to the player. It is moving around the player according to the joysticks position. (As seen in the picture)
Because I want the line to be pixelated (to match the design theme of the game) I cant use the standard LineRenderer component as it doesn't support such pixelated lines. So I started looking for solutions to this problem and stumbled upon Bresenham's line algorithm. After implementing it into the game I knew which x, y coordinates I had to fill with a pixel. Currently every single white pixel in this line is a GameObject with its own SpriteRenderer and a single white pixel as a sprite. In my test scenario up to 400 pixels where rendered at once. I am already using an object pooling system to minimize the performance drag. Moving this line around drops me from around 1100 Fps down to like 200 Fps in the editor. I know it will be slightly better in the build game but I am sure it will take a toll on older mobile devices when enemys, animations etc. are present in the level.
So my question is: Is there a better or more efficient way to render the sprites? Or (preferably) do you have a better idea on how to render this line at all without creating ~300+ GameObjects. (e.g. Shaders (Zero experience), drawing on a texture)
I am grateful for any ideas that lead me into the right direction.
So for some reason my 2D sprites are rendering in a worng way.
In the scene it's ok, but not in the actual game.
What I tried:
Filtering mode: Point(no filter)
Tried different Max Size options
Tried different Pixels Per Unit options
Nothing seems to help, the sprites keep appearing in that strange way, any suggestions?
StackOverflow doesn't allow me to add images to my posts so there they are on imgur.
Scene view: https://imgur.com/X153qQI (proper way)
Game view: https://imgur.com/5R8gpKI
The problem might not actually exist but is probably due to Unity rendering the game in a low resolution to fit it in the game view. Try zooming in by making a high custom resolution for the game view (e.g. 1920x1080) and then zooming in or by lowering the orthographic size of the camera and see if the problem still persists.
As you know positions are critical in multiplayer game and I want to define same position in different resolutions in my 2d multiplayer game.
My problem is like this: if my resolution is 1080p, it works nicely. However if resolution is set to 800x600, then the other character disappears because of the camera.
How can I make it right?
1080p:
800 x 600:
This is one solution that might work in your case : Controlling Aspect Ratio in Unity
change the z of the camera (Camera.main.transform.position =) by using the screen.width and screen.height and make the screen size inversely proportional to how zoomed in (close to 0 on the z-axis) the camera is
The scene
I was wondering about creating
different layers with different Z-Axis values to give more reality like the above picture as it has
1- The green background then
2- The play ground it self then
3- The blurred black trees representing the camera depth of field
So, I thought about Creating the green background then the the black ground with more value of zPosition then the blurred stuff scaled up with more zPosition values, but the problem is when camera moves there is no sense of reality of speed of movement for each layer as they all move together respecting the same positions .
Also I thought about using SceneKit instead as it contains full 3D tools , but the scene is 2D and does not seem to need scenekit.
Thanks in advance as the question seemed too complicated.
Okay, it is figured now.
The answer is gonna be that I put a method that makes the background moves against the camera movement direction with one half or third the camera speed.
As an example
If the camera moves 20 pixels to right , all scene layers seems to be moved 20 pixels to left . So I have to move the background about 8
pixels to right
So all layers seem to be moved 20 pixels to left except that background moved 12 to left, which is slower.
I'm developing a game for mobile platforms. I have a menu with levels. There are a lot of levels so there should be kinetic scrolling. What did I do - every frame I read touches[0].position and based and difference between previous position I move camera.
But, because of the inaccurate touch position (I suppose so) the camera doesn't move smoothly. I'm thinking about calculate average speed for three frames for example and move camera according to speed. Can you give me any advice how to smooth movement?
Also, touches[0].deltaPosition seems to work incorrect.