Search Unity

Lagging / Super slow in play mode

Discussion in 'General Discussion' started by Harper_aimee, Aug 18, 2019.

  1. Harper_aimee

    Harper_aimee

    Joined:
    Aug 25, 2018
    Posts:
    10
    Hello,

    I am hoping that you can help me.

    I have built a big beautiful environment and everything looks great. However in game play the lagging is so bad its almost unplayable.

    I have attached a screenshot of the in play statistics for view, on play there are over 22000 batches. The game runs super smoothly when just under 4000 batches are reached.

    I am new to game dev and have just mastered environment builds after 1 year of practice, can someone advise and give me help with the performance side, what has worked well for you? what exactly can I do? etc.

    Any help would be super appreciated.

    in game stats.PNG

    Thank you

    Aimee
     
  2. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
  3. HavenbrookStudio

    HavenbrookStudio

    Joined:
    Aug 18, 2019
    Posts:
    7
    You need to provide a lot more detail if you want people to be able to help you in a meaningful way.

    What are your terrain settings (if any?) What are the specs for the dev machine? are you doing anything at all to improve optimisation? if so, what??

    1) Are you using occlusion culling?
    https://docs.unity3d.com/Manual/OcclusionCulling.html

    2) Are you using LOD groups?
    https://docs.unity3d.com/Manual/LevelOfDetail.html

    3) Do you have dynamic batching turned on?
    https://docs.unity3d.com/Manual/DrawCallBatching.html

    4) What rendering path are you using? Deferred shading? forward rendering?
    https://docs.unity3d.com/Manual/RenderTech-DeferredShading.html
    https://docs.unity3d.com/Manual/RenderTech-ForwardRendering.html

    5) What quality settings are you using? the Unity defaults? (low, medium..... Ultra) are you using your own custom graphic quality? if so... what's the pixel light count? Anisotropic textures enabled? Vsync on/off? how many shadow cascades do you have? etc

    Without knowing this (and a ton of other choices you have made) it's hard to pinpoint what to improve.

    Just a total guess but I would be surprised if you are using LODs and occlusion culling to their full extent.
     
    Last edited: Aug 18, 2019
    Harper_aimee, Ryiah and Ony like this.
  4. ShilohGames

    ShilohGames

    Joined:
    Mar 24, 2014
    Posts:
    3,021
    Dynamic batching never works as well as it should in Unity. Even for obviously identical objects in the scene. What you want to do is use GPU instancing as much as possible. If you have a lot of units moving around in your scene, you want to even use the DrawMeshInstanced method instead of using GameObjects.

    Use the profiler in Unity to figure out what is using the most time, tweak that, and then profile it again. Repeat until smooth. The profiler will help you figure out what scripts are using most of your time.

    When optimizing a large scene, you can mesh bake objects together to simplify the world. For example, if you have hundreds of rocks in a pile, those do not need to be 100 separate dynamic objects. MeshBake them into a single rock pile. That is just one example of a possible optimization you can make. Do detailed profiling to get an idea what the main cause of slowdown is first, and start optimizing the biggest issues first.
     
    Last edited: Aug 19, 2019
    Harper_aimee likes this.