Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Games Lego Microgame - Super Lag w/ low FPS

Discussion in 'Projects In Progress' started by bshepherd, Sep 2, 2022.

  1. bshepherd

    bshepherd

    Joined:
    Jun 29, 2022
    Posts:
    3
    Hey everyone

    I just published a Unity game on WebGL but it's lagging tremendously lol
    It was pretty bad in the editor too but not nearly as bad as after publishing...

    I put a lot more work into designing it and I'm wondering what could be causing such a terrible experience.. I have a ton of assets and I'm not sure how to really optimize them. There's a lot of moving obstacles but I wouldn't think it would cause such poor performance. I've linked the game.

    Any feedback would be great! Just trying to learn what to fix for the next game I create. Cheers!

    https://play.unity.com/mg/lego/published-build-2
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    4,191
    WebGL is slow. Slower than the editor. But you know that now. ;)

    I get around 10-20 fps when looking into the distance. Facing the character so I don't see much of the world gives me heavily fluctuating 30-60 fps. This is on Chrome with a 1070 GTX.

    There's a number of things that need to be optimized. For one, this kind of fluctuating could mean the CPU is doing too much and/or too much garbage collection happening. You can look into that with the profiler in the editor, any improvement you make there will be reflected in WebGL.

    More importantly, you're using assets that are unfit for WebGL.

    Issue #1 would be render distance - from the start point I can see the entire level. Everything needs to be drawn, even the particle effects in the far distance! You can limit the draw distance by lowering the far clipping plane. This should give you a great speed boost.
    upload_2022-9-3_11-40-59.png

    Issue #2 would be transparency. I bet if you disabled transparency of shaders and removed the particle effects you should see a noticable increase in fps.
    upload_2022-9-3_11-29-59.png

    Issue #3 is not easily solved. These starter kit assets are simply too high-poly for WebGL. The Lego character has a lot of round surfaces which means a relatively high poly count for the looks. But even this item up-close you'll notice the corners have bevels (on the left side the corners are slightly brighter due to the bevels). Means: they aren't 90° angles which means more unnecessary polygons.

    Issue #4 is textures, particularly the skybox. From the looks of it I would say it is at least a 2048x2048 texture, if not higher. That's a lot of memory wasted for the sky that is unavailable for other assets. WebGL is extremely memory limited, more so than any mobile game. I would also expect the textures of other assets contributing more than what WebGL can handle.
     

    Attached Files:

    bshepherd, firstgoapps and Ryiah like this.
  3. bshepherd

    bshepherd

    Joined:
    Jun 29, 2022
    Posts:
    3
     
  4. bshepherd

    bshepherd

    Joined:
    Jun 29, 2022
    Posts:
    3
    Wow! Thank you so much for the detailed response :)

    I'll get to work and make those changes! Cheers!
     
    CodeSmile likes this.
  5. khos

    khos

    Joined:
    May 10, 2016
    Posts:
    1,466
    You can point the camera to an angle so it does not show all the objects all the time, occlude them, that will help with FPS