I have a 2d project that started running extremely slow. I've tried to backtrack what I did but I can't remember what exactly happened that caused this, as it was running perfectly at one point. Here's a screenshot of the profiler:
What I've tried:
Updating my GPU to the latest version
Updating Unity to the latest version
Restarting the editor multiple times
Restarting my PC multiple times
Lowered the framerate via custom interaction mode
I'm quite new to Unity, and quite frankly I'm very lost right now. I've been Googling this for hours now. Any help is greatly appreciated.
Screenshot of profile in hierarchy view:
There should be smth with your grid or tile map, try to turn off those components. If fps raises, try to recreate tilemap/grid
1119.19ms is a solid second meaning you get less than 1 FPS.
For 60 FPS, you should not use more than 16,666ms.
Use the Profiler. (Window -> Analysis -> Profiler) it will tell you what takes up time.
Enable the "Stats" in Game View. For pc, Triangles should be below 6 Million and Batches (drawCalls) should be lower than ~4000 preferably. These numbers are purely for reference on high-end CPU and GPU for a 3D Game, but if you have a BIG difference you should look into that (Like 60k Batches or 20M Triangles would be BAD). GPU Instancing can lower DrawCalls. Making all the non-moving things static in your scene will help as well. Re-Use materials as often as you can. But the most important thing: Profile. You need to know your bottleneck.
You can manually boost performance using simple script
void Start()
{
// Make the game run as fast as possible
Application.targetFrameRate = 300;
}
Related
Im optimizing my game for mobile. For that reason a low amount of batches is important. By using Frame Debug I found out that for some reason the Draw Mesh Node command is performed for every single node eventhough the nodes are static and have the same material as far as I understand. The frame debugger says that the objects cannot be batches because the "Objects have different materials". I dont get why and how to fix that. The nodes are all based on a prefab of them. The only thing that is different between them is their position. Please help
The Frame Debug Window:
Prefab for every node:
Example for one of the nodes in game (ONLY their position is different):
Problem solved after 2 days of being sad and watching every graphic performance tutorital on youtube.
Basically I needed to change every .material code to .sharedMaterial because for some to me unknown reason unity creates a copy of the material when using .material, after which each node got its own material. For that reason the performance was so bad. Now it works and my live quality has increased, since everything gets batched, reducing the draw calls from 300 to 10 :)
I hope future readers are helped by this!
This is posted here since this is Xbox specific, but I am also posting this onto the Unity forums.
When testing my Unity game on Xbox One I am getting a very large amount of visual "jitter" from the ball. This is a skeeball game where you control the movement of the ball. Essentially the core of the movement is similar to the Rollerball tutorials. On PC this works fine and there are no perceptible jitters. However, on Xbox, I am seeing this a lot more. The object is travelling large distances with the camera following smoothly behind. None of the other objects or scenery are affected, I actually think the camera itself is moving perfectly. But, the ball itself seems to glitch.
Changing my camera movement to LateUpdate seemed to minimize it the most on the PC, but that doesn't make sense to me since I am still not convinced the camera is the problem.
Any help would be greatly appreciated. Perhaps a quality setting isn't placing nice with the Xbox?
Thanks!
Nick
Keep in mind the clock speed of the CPU on the Xbox is likely much slower than your PC (although there are more cores).
Unity is primarily single threaded, so that could explain the performance difference. Here are some things you can try:
* Make sure you are running the "Master" build on Xbox. The default is "Debug" which is significantly slower.
* It's possible it's something with the physics.
Once you've checked to make sure you aren't running Debug, the next step would be to use the Unity profiler to see where your frame time is being spent, then depending on what the cause is optimize that part.
Here is more information on the system resources:
https://learn.microsoft.com/en-us/windows/uwp/xbox-apps/system-resource-allocation
There is also a great post about the graphics debugger here:
https://tarhik.wordpress.com/2017/09/04/antimatter-instance-dev-log-entry-2-using-microsofts-graphic-debugger/
It looks like switching the RigidBody to use "Extrapolate" instead of "Interpolate" fixed the issue I was seeing. I am not sure if this works for every situation, but for the scale of the levels and the player physics of my game this seemed to do the trick.
My daydream app is working fine when used slowly. But when I rotate my head too quick it starts giving glitches first and then the app gets crashed. I am guessing it has to do something with frames/sec loaded during high quality objects rendering or something similar. If someone has a solution, please help me out.
Assuming you have no errors in logcat, visual glitches are generally indicative of extremely high per frame GPU load.
It would be good to profile your app and share the crash report - but the only way I've ever been able to actually crash an app this way is with very large textures.
Check the size and number of textures in your scene - it's possible rapid head rotation could be causing a large number of textures to need to be loaded as objects become visible. You can also see a good list of how large the assets are at build time in Unity by inspecting the editor log after a build. This can help make sure you aren't running out of RAM on device.
Make sure you have texture compression and mipmaps enabled on all textures. Disabling mip-maps on minified textures can easily overload the GPU.
Make sure you don't have too much transparency. Adding a lot of overdraw to the scene can overload the GPU.
Follow performance optimization guidelines https://docs.unity3d.com/Manual/OptimizingGraphicsPerformance.html
https://unity3d.com/learn/tutorials/topics/virtual-reality/optimisation-vr-unity
Make sure renderViewportScale is around 0.7, MSAA is at 2x or less, and you aren't using post-process effects, shadows, or any kind of deferred rendering
Stay below 100 draw calls, 200k vertices on screen.
I have been building a game for VR using Unity3d. It has only low poly models and the file size is less then 40 mb still the game lags when played on mobile.. Please suggest how to improve the performance..
Thank you in advance..
In order to improve performance in VR for mobile you have to optimize everything as best as you can, you should keep some of these variables in mind:
Graphics Side
- Number of polygons in the scene
- How many source of lighting do you have
Programming Side
- How much work is taking your code, is doing it efficiently?
The programming part can include problems within the physics system, also some logic problems that can probably decrease the overall performance because of higher computation.
My advice is to learn about the Profiler that unity offers, actually you can observe how much work is taking your code and where exactly it is your bottle-neck. This video also can be useful.
Of course a solution could be implement your code following design standards, like design patterns and software architecture (depending on the size of the project).
I hope it can be useful for you!
What I found from developing and launching a vr game is some of the issues below
Number of polygons is usually your first to check even though your models are low poly. For example, I looked at Synty models in the unity store and some of them were over 1k for a bag and 7k for a character model. This seriously reduce the amount of objects you can if you want to target a max of 50000 per eyes.
With some models, you can use blender and the decimate tool to reduce the polygon count pretty easily. From there I would use LOD's to reduce their count further based on distance.
Use occlusion culling (pro version only)
Set your camera distance to maybe a 100 instead of the default
Use mobile shaders and careful using some of the standard shaders as they are expensive. Also transparent shaders will becomes expensive cause overdraw.
Batch your textures and make them static if possible
Don't use dynamic shadows on lighting but instead bake your lights
Try to avoid using physics as this becomes expensive and instead raycast to trigger events or shooting weapons.
Run profiler often and check for any bottlenecks (pro version only)
Reduce the count of Particles effects and their values
Character bones can also cause issue so remove as many as possible
There is also your code to look at as mentioned by Manujamming
Set quality setting to low in the inspector to gain best performance.
Could you provide a screenshot of your game scene?
I hope this makes sense.
Best of luck!
I am using particles for an iphone application using cocos2d. The framerate drops as the particles are shown. What is the best way to clean these up as not to affect performance?
I using too many particles that was taking up too much memory. I changed the way I did things.
I've written a tutorial on how to pool and reuse particles. I found that even though I was removing my emitters with cleanup they were still sitting in memory. After pooling the number of active particle systems dropped from 700 after 2 minutes to 34. The tutorial can be found here.