Search Unity

I need some tips about optimization of a fighting game in Unity 3D

Discussion in 'Game Design' started by jsrousseau, Jul 4, 2018.

  1. jsrousseau

    jsrousseau

    Joined:
    Apr 29, 2018
    Posts:
    1
    This is my last year at university, my team is creating a fighting game based on high-fantasy elements. We already did 30% of the project and we bought UFE (Universal Fighting Engine) so it could help us on the process, but I still feel that something's not working correctly, the controls' responsive isn't good, the FPS is too low, and we have no advanced knowledge about how to optimize a game, it would be awesome to have some tips. Thanks already :)

    ps: i'm not really sure i've posted on the right place but i can't find where to delete the topic, sorry mods :(
     
    Last edited: Jul 4, 2018
  2. BIGTIMEMASTER

    BIGTIMEMASTER

    Joined:
    Jun 1, 2017
    Posts:
    5,181
    enable stats in the scene view to see what the total tri count is in your scene. I found out recently that some placeholder teeth and eye models I was using were multiplying the tri count tenfold -- into the millions -- because of the lighting calculations.

    Also, atlas/pack whatever textures you can, and find the minimum resolution for each material to hit your target quality. Most of your environment textures are probably imported at 2k, but in most cases you only need 512.

    If you can reduce your 3d assets density by using LOD's, do that. What I mean by "if you can," is that if you can take away 25-50% of a character/props polygonal density and it doesn't show obvious degradation at a given distance, do that. No sense rendering anything invisible to the human eye.

    Beyond 3d asset optimization, I can't help. I think lighting and post-process are probably the biggest detriments to performance, assuming everything else isn't a total catastrophe.
     
  3. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Start with the Performance Optimization page. Figure out what's making it slow first. That page will show you how to use the profiler, and then what steps to take once you know what's hurting performance.
     
  4. BrandyStarbrite

    BrandyStarbrite

    Joined:
    Aug 4, 2013
    Posts:
    2,076
    A fighting game? Cool!

    If it's a classic one vs. one fighting game, like Street Fighter, or Virtua Fighter
    or Fighting Ex Layer, having 2 players on the screen and a stage, should
    be a breeze.

    But if it's a fighting brawler game like Powerstone 2, where 4 characters
    are on screen at the same time, then a good bit of optimisation might be needed. Especially if your characters and enviroments, have a large number of polys.

    Also, we have no idea, of the polycount of your characters and enviroments.
    And the sizes of the textures, used in your game.
    Can you give us a rough estimate of them?
     
  5. newjerseyrunner

    newjerseyrunner

    Joined:
    Jul 20, 2017
    Posts:
    966
    I too would check out your assets. You should keep in mind that most assets come in much higher quality then is expected to be used in a game. If you go to 343, they have a model of the master chief that probably has millions of triangles. That model never makes it to the game, they use their software to bake the small details into a normal map then decimate the hell out of the model.

    Remove everything that's not necessary. Personally, I found the biggest cause of triangles in my scene were eyeballs. I used to use spheres for eyeballs, but now I use a triangle fan and limit it's movement.
     
  6. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    Don't waste a second of time on checking assets or light mapping or LODs or script optimization until you have established where the bottle neck is. Establish where the bottleneck is by running the profiler.

    The profiler is your friend. Listen to what it says. It will tell you exactly why your performance is struggling.

    Once you have the profile, come back and get specific suggestions.
     
    angrypenguin likes this.
  7. unitedone3D

    unitedone3D

    Joined:
    Jul 29, 2017
    Posts:
    160
    Hi there, just a 2 cents. I too am developing a fighting game (2.5D fixed plane with 3D character models); I also use UFE. Many have stated great helping leads, I would add to check your backgrounds, how poly heavy is it on each fighting stage, can you switch for 2D image BG instead of real 3D background/you can do parallax layers to create the effect of depth (juxstaposed 2D layers in the 3D horizon/the layers closer or father from the camera create the feeling of 3D depth (ex: grass ground layer is very close to camera, trees layer is a bit farther behind, and sky/sun is the farthest away from camera. When camera will pan left and right, the illusion will sell it, and we will feel the ground is very close while sky/sun very far, and trees in between). Making parallax layers is very tedious, but building 3D backgrounds for fighting games is also very time consuming (unless they are botched/uninspired/unaesthetic), and very taxing in terms of polygons/texture loads. In mycase, I solved it with static 2D images as BGs, by making the perspective effect is very visible in that 2D image (''fish eye lens effect''),
    I wanted to do beautiful photography parallax effect but my image matte/plates would have to be chopped in many layers (you only 2 or 3 for a minimal pseudo depth effect, but for a true 'deep' depth effect you need at least, 4, 5 or 6 layers. At 10 layers per stage, the effect is very smooth/deep/obvious.

    Your backgrounds polygon count could munch way too much resources, check the profiler; as others said, 3D poly LODs can solve this partly. Also, culling/hiding, camera culling - anything outside camera visual periphery and by distance to camera, becomes invisible/hidden. In my case, by substituting 3D for 2D BGs, I was able to put more polygon budget on my 3D fighters. Essentially, Unity has a 65,536 tris limit per object (16*4) a limit imposed on 3D files such as .3DS, but you can combine them inside Unity for a larger total.
    65,536 tris = 22,000 polygons. This is approx. Xbox 360 level 3D fighters, on the low end/slightly chunky.
    For example,
    SFV has poly count of 50-60,000 polys per character.
    SF4 has 30 000 or so.
    Tekken 7 on PS4 has 60-70,000 poly per character.
    Tekken 4 on PS3 from the haydays has 20-40,000 polys.

    But, as one specified, the trick is mapping 'normal maps' that simulate higher polygons count but cheat it by
    2D texture baking. It's an optical illusion that makes the model look millions of polys but is in fact barely 100,000 polys.

    What's more, is how you compartmentalize your polygons :
    You can put 49,000 polys on a character's shoes, but then you have just a 1000 left for the entire rest of the body if working with a 50,000 poly budget per character. That's not wise nor suggested - unless you focus on their shoes the whole time - it's poor optimization. You may want more polys/detail clustering around specific body areas (like the (detailed) face or the hands, both highly expressive and needing higher polys/clustering to convey the character's expressive facial and hand fingers gesture detail); but, overall, you want to 'spread' the polygons budget Equally on the entire model - so that it looks good from everywhere - if certain areas are not so important then you can recluster these less important areas polygons towards important high detailed areas (such as face/hands).

    I noticed that when I did 100% spreading of polygons on a model, certain areas were less detailed But, the Overall feel was much Smoother: the spreading caused a 'rounding' effect where it looked good from every angle but not as detailed in certain areas if I had clustered/'concentrated' the polys budget in ccertain areas only (like just the face alone, to get a more detailed hi-res face, and a low-res body)). The characters looked 'filmic' realistic when polygons was 100% spread equally all over (but slightly less detailed/buttery look lacking detail-in certain areas), while when I clustered them in certain areas, the characters looked less 'filmic' but more 'gamish/cartoonish' - my take : for cutscenes focusing on specific body parts, clustering polys is better but cutscenes are suppose to be 'filmic' - but the model looks gamish - as long as you focus the camera only the higher polygons detail- areas it does not show that much even if the camera is Very Upclose to the model.
    While during the fighting game, spread polygons is best, as the characters are farther from the camera and require less detail/they move so fast your eye doesn't pick up detail- as well as in a closeup cutscene. Plus, as said and as an added bonus, spread polygons 100% equally means characters that look 'filmic' less gamish (this is seen in CGI in films, upclose 3D CG monsters in films VFX must stand the test of eye scrutiny : the CG VFX studios use 100% spreading of polygons = more costly long rendering - but the 3D monsters Stand the test of eye scrutiny Even Very Upclose to the camera : lack of polygons in areas is unbalance look/cartoonish look not realistic ))).


    In the 30-70,000 poly range your game should stay fluid 60fps 1080p for 2 characters (150,000 poly total) with 4K texture compressed on mid budget Nvidia/Radeon GPU card. But no 3D BGs, the 3D BG could chomp another 50-150,000 poly depending on its detail/if it's occluded culled LOD or not/total Number of Objects in BG- this could reduce 25-50% frame rate. Plus, as said, number og lights/types/HDR or not/skybox or not/GI or not ( baked lighting is best).

    Hope this helps in any way and good luck,
    Thanks for reading.

    Just a 2 cents.
     
  8. BrandyStarbrite

    BrandyStarbrite

    Joined:
    Aug 4, 2013
    Posts:
    2,076
    Don't forget to tell us, what platform you're aiming for? :)
    eg. pc, mac, tablet?
     
  9. BrandyStarbrite

    BrandyStarbrite

    Joined:
    Aug 4, 2013
    Posts:
    2,076
    You can also use, a half of a sphere, similar to a cut orange, for an eyeball too.
    Or something a slight bit more than that.
     
    Last edited: Jul 21, 2018
  10. Sluggy

    Sluggy

    Joined:
    Nov 27, 2012
    Posts:
    983
    I'm going to echo Kiwasi here because this is important, real-world, problem solving, advice. Profile first! You are completely and utterly wasting your time with shots in the dark until you actually know what the problem is. Profile!
     
    BrandyStarbrite and Kiwasi like this.
  11. BrandyStarbrite

    BrandyStarbrite

    Joined:
    Aug 4, 2013
    Posts:
    2,076
    Hey, what's up? :)
    So how's your game going so far?