Search Unity

How can i optimize having lots of objects

Discussion in 'Scripting' started by xred13, Jan 1, 2019.

  1. xred13

    xred13

    Joined:
    Jul 14, 2018
    Posts:
    74
    Hi, so i have made kind of like a racing game, where in the beginning i instantiate the whole race and all the objects one by one. The problem is that i get really low fps, how can i optimize my game to run more smoothly with many objects?
     
  2. SparrowGS

    SparrowGS

    Joined:
    Apr 6, 2017
    Posts:
    2,536
    How much is many?

    Check out the profiler to see where the slowdown is exactly to see what can be done.
     
  3. xred13

    xred13

    Joined:
    Jul 14, 2018
    Posts:
    74
    I do not know what you mean with "see where the slowdown is exactly" so here is a screenshot of profiler.
    I will see how many objects are spawned..

    upload_2019-1-1_23-35-22.png
     
  4. xred13

    xred13

    Joined:
    Jul 14, 2018
    Posts:
    74
    About 700 obstacles and 132 lights (those little things on the sideways)

    upload_2019-1-1_23-42-50.png
     
  5. xred13

    xred13

    Joined:
    Jul 14, 2018
    Posts:
    74
  6. SparrowGS

    SparrowGS

    Joined:
    Apr 6, 2017
    Posts:
    2,536
    700 objects is far from a lot, try 10K and then hit me up.

    your problem is probably the 132 real time lights, I assume they are real time because you Instantiate everything on start, do you actually need them to shine?
    if not you can just turn on the material "emission" to make it glow(with a touch of bloom).

    also tick on "material instancing" or what ever it's called on all your materials, it's one of the last options.
     
  7. DownER149

    DownER149

    Joined:
    Sep 11, 2018
    Posts:
    61
    object pooling