I have a problem with surface light flickering on android devices. I have tried everything I found online including changing near/far clipping planes of the camera, changing some quality settings like cascade shadows, turning shadows off/on, limiting to just one light source but I always get this problem. Everything looks OK in the editor.
Models in my game are made of multiple smaller 3d objects and it is always few of them that get this glitch.
This is how it looks:
You say that your models are made from multiple smaller models. Are you sure this is a lighting issue and not a z-fighting issue?
This can happen when two planes are in the exact same place, and which one is in the front can randomly change from frame to frame giving a flickering effect.
I could not find a credible Unity source explaining this issue, but here's a link to the Wikipedia on Z-fighting
As far as I know the only solution is to change your models to make sure the overlapping doesn't happen. Either my moving one of the planes down or deleting one of them.
Related
I'm following a unity tutorial and made a very basic top-down 2D scene using tilemaps. Starting up the game the rendering seems fine, but as soon the camera moves along the Y axis, the tiles seems to "move apart". Also, the sprites I use seems to get an offset for the tile-map, as if they were cut incorrectly. (1 pixel dilation on the y axis.)
Before moving:
After moving:
Any ideas why this happens and how to deal with it?
My issue seems to be something like this one, but there were no answers here. Another thread found a solution to a similar issue, however I couldn't make this work, as Unity does not allow me to directly change the Pixel Snap property of the shader, but says "MaterialPropertyBlock is used to modify these values".
I have some ideas here:
I found this video which uses a SpriteAtlas to alleviate a similar problem. The person mentions also setting the Filter Mode to Point for the Sprite Atlas, along with Compression set to High Quality.
Also double check that your sprites are setup the same way... Point (no filter) and High Quality Compression. I think I remember there being an option for NO compression... that might be worth a shot as well, since I think that most 2d images are already compressed.
I also remember there being a "Pixel Perfect Camera", as documented here:
It specifically mentions being a good solution "which ensures your pixel art remains crisp and clear at different resolutions, and stable in motion.". The basic idea is that you use the Pixel Perfect Camera Component, and use settings similar to what was mentioned above.
For your sprites:
Filter Mode: Point (no filter)
Compression: None
Use the same Pixels Per Unit for each
With the Sprite Editor, set all the sprites Pivot Unit Mode to "Pixels".
Set your snap settings to 1 / Asset Pixels Per Unit (and apply to existing Game Object)
There are also specific settings for the Pixel Perfect Camera component.
This is possibly just a floating point precision error caused by your tile calculation somewhere.
There are a number of complex fixes that are the "right" way to do it, but a quick an easy fix is to move the tiles closer together by a very small amount (0.0001f). If this doesn't fix it, its probably not a precision error.
This is my first time to make a Unity project. Everything works well on the Game view in Unity Editor. However, after I built the project and played it on Google Chrome, I found that the position of some gameobjects had been changed.
Here is a more detailed explanation. The left is what I saw on the game view, which was perfect. The right side is what I saw after built the project. The position of the grey picture had been changed.
Does anyone know how to fix this?
ps.I am using Unity 2020.3.18 with WebGL platform
Try exporting again but with the same resolution as the game view. In this case you would want to export in a 400x600 resolution (You can also edit the "index.html" file to change and experiment with the resolution). The problem has to do with the fact that changing the resolution of the game can affect where certain objects are and how much you can see.
I started up a new URP project with everything pretty much default.
When I first loaded in a scene I noticed some weird shading issues. There were two concentric circles that were shaded in a way that it seemed like a depth of field effect. I wasn't sure how to get rid of them, so I moved on.
I got a basic first person controller and discovered more strange artefacts as I started walking around weird line imperfections within the grids and such, and the weird depth of field of effect I found in the scene view carried over into the game.
I've tried to searching around to find out if anyone else has had this problem before me, but I couldn't find anything. I've also tried to change post processing settings as well as some basic lighting settings. Nothing seems to fix the issue.
This video shows the issue a little more closely: URP Artifacts
Ok, I fixed it by just creating a new project that did not derive from the URP template. Then I just manually converted it to URP.
I don't know why this happened when I was using the template. I don't know why this works. Probably it has something to do with the initial settings that come with the template, but that is just conjecture.
I have made a very simple hypercasual game everything works fine but after some few minutes of gameplay, the fps goes from 60 to 50 even the phone gets heated up. Similar to this question. I tried profiling but just can't see anything off. Tried even removing some UI elements but still no luck. Tried various vsync settings. Also, I had used this to display the fps. Even without it, the lag can be seen. Even if I just open the game and do nothing then after 5 minutes the fps will become 50. If go back using the home button and re-enter the game then the fps becomes 60 again. Using unity 2018.2.6f1. Never experienced this behavior in my other Android games.
Basically it was a faulty custom vertex shader which was applied to a plane to change the background color which changed color over time. I had not used the mobile vertex color because I was not getting the desired output. But now I'll stick to the mobile one.
The two symptoms you observed are very much likely to be connected.
The phone might heat up, as you are using its full power, which in turn makes the throttling kick in, reducing the perform
I've had the EXACTLY same problem. I was trying to fix it for a very long time. You said something about faulty shaders you use. And this is the key to solve our problem.
I use a 2-color gradient as a BG, so I have to use a shader too. Due to the fact that I'm a total noob in the writing "shader-code", I have to find something in the Internet. And it was my biggest fail)
To fix the problem and remove this fps drop you should remove your gradient and shader attached to it from the scene. And try to find a more optimized shader for 2D-game (or you can always write your own one c:)
I'm currently creating a 2D Android and iOS game using Unity3D engine. I'm testing the game on a nexus 5, and an iPhone 5s device. Everything until now is working fine and I am pretty happy with the result, but when I test that application on an iPad or a Samsung tablet all the objects in my game scene are not in the correct position anymore. Is this a common problem in Unity3D ?
I know I am missing something but I tried to do some research and what I found is only by changing the orthographic camera scale might fix this problem, but I found it as a big amount of code to write as my game have not only one scene but multiple scenes and every scene have it's own game objects.
Is there any other method to do, a good and simple work around for this problem?
It's all about setting the Anchors right.
If you're using the new UI System, make sure you anchor the objects where you want them to be, that's how you will achieve resolution independence.
For more information about anchoring, see this tutorial
Don't have separate scenes for separate devices. You can use the Screen object to check the height and width of your display. Then you can use this to set the orthographic size of your camera to something that makes everything visible as expected.
Update: I misunderstood your question, you say GameObject, i understand UI.
Please check this. I don't have this issue on my game. But when i try it with mac or windows machines, it is problematic. So maybe this can solve.
Other solution is more common which is you and Agumander say, change orthographic size of Camera.
This Is for UI
You can use Unity UI, and don't need to seperate. There are so many different resolution and density devices, you need to create so many scenes. So it is meanless separating scenes.
Unity UI has pixel based solutions which can be very helpfull for many density and resolution options. Forexample, It has VerticalLayoutGroup and HorizontalLayoutGroup for easy list like element visulation.
Most important thing is: Do you want to change UI for different screen size or resolutions? For example iPad has larger screen so user can be see more content. This change UX. Maybe you need to consider this.