Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question How could I optimize this Game Idea?

Discussion in 'Editor & General Support' started by SKULLgaming8777, Dec 3, 2023.

  1. SKULLgaming8777


    Dec 11, 2021
    I am making a VR Game where you use Rigidbody wooden building parts to build a base. You use screws to connect multiple parts together which allows you to make a bunch of stuff.
    That is just a super dumbed down version of what I am doing right now but one thing I've been wondering is how ill optimize this game.
    I am imagining that once you get to a certain amount of rigidbodies that have multiple joints to connect eachother the game would become pretty laggy. What do you guys think I could do to optimize the game to increase performance when the number of wooden parts increases?
  2. Kurt-Dekker


    Mar 16, 2013
    So you're optimizing vaporware?

    For all performance and optimization issues, ALWAYS start by using the profiler:

    Window -> Analysis -> Profiler

    DO NOT OPTIMIZE "JUST BECAUSE..." If you don't have a problem, DO NOT OPTIMIZE!

    If you DO have a problem, there is only ONE way to find out: measuring with the profiler.

    Failure to use the profiler first means you're just guessing, making a mess of your code for no good reason.

    Not only that but performance on platform A will likely be completely different than platform B. Test on the platform(s) that you care about, and test to the extent that it is worth your effort, and no more.

    Remember that you are gathering information at this stage. You cannot FIX until you FIND.

    Remember that optimized code is ALWAYS harder to work with and more brittle, making subsequent feature development difficult or impossible, or incurring massive technical debt on future development.

    Don't forget about the Frame Debugger either, available right near the Profiler in the menu system.

    Notes on optimizing UnityEngine.UI setups:

    At a minimum you want to clearly understand what performance issues you are having:

    - running too slowly?
    - loading too slowly?
    - using too much runtime memory?
    - final bundle too large?
    - too much network traffic?
    - something else?

    If you are unable to engage the profiler, then your next solution is gross guessing changes, such as "reimport all textures as 32x32 tiny textures" or "replace some complex 3D objects with cubes/capsules" to try and figure out what is bogging you down.

    Each experiment you do may give you intel about what is causing the performance issue that you identified. More importantly let you eliminate candidates for optimization. For instance if you swap out your biggest textures with 32x32 stamps and you STILL have a problem, you may be able to eliminate textures as an issue and move onto something else.

    This sort of speculative optimization assumes you're properly using source control so it takes one click to revert to the way your project was before if there is no improvement, while carefully making notes about what you have tried and more importantly what results it has had.

    "Software does not run in a magic fairy aether powered by the fevered dreams of CS PhDs." - Mike Acton
  3. marcoantap


    Sep 23, 2012
    Yeah, combine all that into a single mesh and mesh collider. There are utilities in the Asset Store to do that dinamically.