Search Unity

Question Low framerate for first ~20 seconds when testing game in Unity

Discussion in 'Getting Started' started by Blaell, May 16, 2023.

  1. Blaell

    Blaell

    Joined:
    Sep 29, 2022
    Posts:
    2

    Hello, first time game maker, first time writer.
    I'm creating a relatively small Unity game that involves no more than turning objects on and off and collecting some items.
    When testing the game, the framerate is somewhere around 0.5 and the CPU main hits up to 2000 ms. After about 20 seconds, it runs perfectly fine without any issues. I am not using any extensive packages or assets, this began after I was testing out some code for a moving platform. See screen shot for specs.

    Anyone know why this might be?
    Running on Mac M1 8gb ram, Unity 2021.3.19f1
    Thanks
    E
     

    Attached Files:

  2. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,780
    Please show use more content. It is impossible for us to guess work.

    Your scene has lots of features, so chances is, anything else is happening.
    Use profiler, to see what is going on.

    Also, is looks like it belongs to getting started, or scripting sub-forum.
     
    Blaell likes this.
  3. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    7,938
    I would learn how to use the profiler to figure what exactly is drawing so much overhead, then you can focus on that specific issue.
     
    Blaell likes this.
  4. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    6,005
    Just a thought: if you have a large stack of physics objects they will slow everything down while the ycontinue to collide with each other and this behaviour eventually settles when the number of contacts gets less and/or bodies fall asleep.

    The naive cube-of-cubes „voxel“ approach will lead to such an issue for example.
     
    Blaell and spiney199 like this.
  5. Blaell

    Blaell

    Joined:
    Sep 29, 2022
    Posts:
    2
    Much appreciated! I had a look and familiarised myself with the Profiler, but the issue in the end was indeed too many objects colliding with each other. Deactivated a few and it runs normal again. Thanks!
     
    Antypodish and spiney199 like this.
  6. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    21,205
    I recommend moving to a higher amount of memory as soon as you're able to afford it. I have an M1 w/ 16GB RAM that I use for making builds. With just Unity and the processes needed for the OS I never see more than a few GBs free. Just 8GB isn't going to be viable for very long.

    Modern OSes are designed to avoid running out of memory completely by using the drives in the system as a form of memory but there is a substantial performance penalty associated with that not to mention it increases the wear and tear on the drives shortening their lifespan.
     
    Last edited: May 17, 2023