Announcement

Collapse
No announcement yet.

Move Component FPS Drop

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Move Component FPS Drop

    Why does my game run at 60 fps on a smartphone (galaxy s4/ p9 lite) but if I spawn some enemies my FPS decrease (1 enemy = 1/2 fps less)? I use the mobile mannequine.
    The problem is the move component.
    Click image for larger version

Name:	withoutenemy.png
Views:	1
Size:	613.1 KB
ID:	1208515
    Click image for larger version

Name:	10enemies.png
Views:	1
Size:	563.5 KB
ID:	1208516
    Click image for larger version

Name:	20enemies.png
Views:	1
Size:	635.1 KB
ID:	1208517
    Click image for larger version

Name:	45enemies.png
Views:	1
Size:	624.7 KB
ID:	1208518
    Click image for larger version

Name:	80 zombies.png
Views:	1
Size:	507.5 KB
ID:	1208519
    Click image for larger version

Name:	moveEnemy.png
Views:	1
Size:	86.2 KB
ID:	1208520
    Click image for larger version

Name:	moveenemyFunction.png
Views:	1
Size:	93.7 KB
ID:	1208521

    P.S.
    The screen are taken in the editor on low settings.

    #2
    Anyone, please?

    Comment


      #3
      Originally posted by piromane961 View Post
      Anyone, please?
      How are the FPS when you do not move the actors each tick?

      Moving those 80 actors is not cheap, you know? Each one has to compute physics, animate, update path info, etc.
      For a desktop PC or a console this might not be such a big problem, but I guess an older phone such as the S4 does reach its limits with so many complex updates.
      Particle Editor Extension: Marketplace Page | Documentation
      Code plugin which extends your particle effect toolbox with new possibilities.


      SVG Importer Plugin: Marketplace Page | Gumroad Page
      Import SVG (scalable vector graphics) files as rasterized rendering or as multi-channel signed distance field.

      Comment


        #4
        You call your function every 50 ms. That is 20 times per second. That function uses "Move to Actor".

        From the documentation:

        > Makes AI go toward specified Goal actor (destination will be continuously updated), aborts any active path following

        So the destination of each AI is updated each frame based on it's current path (relatively good performance because the path is only updated, not calculated anew) which you (unintentionally) abort every 50 ms and recalculate for every AI.
        Pathfollowing is quite expensive and leaves lots of room for optimization in general. This alone could explain at least a large chunk of the performance loss you experience when spawning enemies.

        So try changing that. Maybe that will take care of your issue already!

        Comment


          #5
          Originally posted by Cultrarius View Post
          How are the FPS when you do not move the actors each tick?

          Moving those 80 actors is not cheap, you know? Each one has to compute physics, animate, update path info, etc.
          For a desktop PC or a console this might not be such a big problem, but I guess an older phone such as the S4 does reach its limits with so many complex updates.
          I spawned 250 enemies without calling any functions to move them (but they had the ai controller). The fps went from 70-75 to 25. I think it happened because each mannequin has around 10k triangles, so 250 * 10000 = 2.5 million triangles. I know I have to make a character with 2k triangles or so. Btw I will not spawn 250 enemies in my game.
          I also spawned 250 moving enemies and the fps were 8-10.

          Comment


            #6
            Originally posted by Erasio View Post
            You call your function every 50 ms. That is 20 times per second. That function uses "Move to Actor".

            From the documentation:

            > Makes AI go toward specified Goal actor (destination will be continuously updated), aborts any active path following

            So the destination of each AI is updated each frame based on it's current path (relatively good performance because the path is only updated, not calculated anew) which you (unintentionally) abort every 50 ms and recalculate for every AI.
            Pathfollowing is quite expensive and leaves lots of room for optimization in general. This alone could explain at least a large chunk of the performance loss you experience when spawning enemies.

            So try changing that. Maybe that will take care of your issue already!
            You mean I call my function every 50 ms because I set the timer to 0.05? I spawned 50 enemies and my fps were 36, then I unchecked the looping and the I gained 6 fps! I can disable the the looping becuase I just find out that the TrackPlayer function can be called just once to work.
            Do you know how to change the Pathfollowing?

            Comment


              #7
              Originally posted by piromane961 View Post
              I spawned 250 enemies without calling any functions to move them (but they had the ai controller). The fps went from 70-75 to 25. I think it happened because each mannequin has around 10k triangles, so 250 * 10000 = 2.5 million triangles. I know I have to make a character with 2k triangles or so. Btw I will not spawn 250 enemies in my game.
              I also spawned 250 moving enemies and the fps were 8-10.
              You may not move them, but they are still ticked and animated, right? With 10k triangles each that is a lot of updates to process each frame.
              Honestly, even 2k triangles is too much for mobile if you want to spawn 100 of them.

              Also, what Erasio said: spread the AI workload more or just remove the AI controller completely and move them yourself (if your level design stays like your screenshot).
              Particle Editor Extension: Marketplace Page | Documentation
              Code plugin which extends your particle effect toolbox with new possibilities.


              SVG Importer Plugin: Marketplace Page | Gumroad Page
              Import SVG (scalable vector graphics) files as rasterized rendering or as multi-channel signed distance field.

              Comment


                #8
                First of all. Yeah. That makes quite a lot of sense that the poly count costs a lot. With animation it means the system has to do modifications per vertex instead of just rendering. For a mobile device that is quite insane.

                You should not try to modify the pathfinding code yourself. Epic has create a quite good system.

                But there are a bunch of settings you can play with in the Project settings under "Navigation Mesh".

                Apparently there is also a crowd manager module. Just found that myself so no clue what it does or if it's useful for you. But crowds sound like something you do.

                Comment


                  #9
                  Originally posted by Cultrarius View Post
                  You may not move them, but they are still ticked and animated, right?
                  They weren't ticked but they did animate. I spawned 450 enemies without controllers and animation and i got 45 fps. Cool!

                  Comment


                    #10
                    Originally posted by Erasio View Post
                    But there are a bunch of settings you can play with in the Project settings under "Navigation Mesh".

                    Apparently there is also a crowd manager module. Just found that myself so no clue what it does or if it's useful for you. But crowds sound like something you do.
                    I tried to move the enemies without a AI controller but it doesn't work. I thought enemies must have a controller. Could you explain how to do it, please?
                    I tried the crowd controller and changed some options but the fps are almost the same

                    Comment


                      #11
                      You should start out by properly pinning down what exactly is causing your issues.

                      Check out this documentation page:
                      https://docs.unrealengine.com/latest...iew/index.html

                      If your bottleneck is the amount of polys / animation. There's no point in optimizing tick / gameplay further.

                      To answer your question regardless: Enemies don't need to have an AI controller. You can implement behavior without. You can also code your own movement instead of using unreal engines nav mesh and movement code.
                      I find it unlikely though that this is causing your FPS to drop this significantly. Coding your own pathfinding / movement isn't trivial and the chances that you'll gain a serious improvement by doing that is unlikely. It certainly will have less features (because you would have to code all of that yourself) which will definitely end up worse in the long run.

                      Comment


                        #12
                        I am gonna post a lot of tests so everyone can see how I improved my fps.
                        Thanks guys
                        Last edited by mauiboss.; 05-30-2017, 06:19 AM. Reason: :(

                        Comment


                          #13
                          I could not find a way to improve FPS, unfortunately

                          Comment


                            #14
                            I'd honestly be wary of doing large groups of AI on a mobile device, the default Character and its associated path-finding isn't exactly the most optimized for large groups of very active AI, even on PC having a blueprint-based character will be relatively complex to maintain 200+ AI on decent hardware. Nativizing blueprints to C++ on full game compile/packaging might speed things up considerably (there was a drastic difference at least for me when my AI was nativized) Running in PIE will be the slowest, running in standalone will be closer to actual performance, and running compiled/packaged will of course be the actual end-result in terms of speed.

                            If it's a mobile game, you can spend time optimizing by doing things like disabling collision between certain actors, literally having AI be enabled/disabled per frame in groups or on a level-of-detail/distance basis where you do simple math to calculate around where the AI might of been if he was still "moving normally" while offscreen and update his location periodically, etc.

                            As an example, for more expensive routines I have in my AI I have a counter as it iterates through an array of my currently active AI actors, and stops iterating through the loop when the counter reaches it's limit such as "20." When completed it remembers the last index it left off on, and so when it runs the next frame the counter is reset, and it picks off at the last index it passed through in doing its routine. (Of course if the last index was the last index in the actual array, it resets to start off again from index 0 if not empty)

                            You can also possibly go the route of games like civilization where its actually just one actor/unit that has multiple character models or animations attached to it. X3 terran conflict by egosoft is a pretty good example of two different methods of AI that allow the game to simulate thousands of ships in the game universe. It literally has two methods, "in-sector" where the current streamed map/3d space the player is in is fully loaded with physics simulations and fully-loaded/most expensive ai, and "Out-of-sector" AI, where the game is doing mathematical simplifications to abstractly represent the ships moving towards their destinations as well as any possible battles/damage that might of occurred with other ships in its area. (Fun fact, certain ships perform better in-sector such as nimble fighters because of the speed at which they move, and perform poorly out of sector/get mathmatically eliminated quickly due to their total health/weapons being the few attributes taken into the simplified equation or vice-versa)

                            Along with AI, the most costly factors I've found in terms of AI are getting new paths/dynamic regeneration of paths, collision if a ton of actors bunch up (I can have 1000 physics models of spaceships fly around with thrusters and steering on my pc at 60fps, but when a bunch of them collide into each other at the same time, queue the major frame hit), anything with a large amount of entries in an array that need to be done in one frame (at least in blueprints), and the total amount of draw calls/materials/etc.

                            Keep in mind that bone count, skeletal animations and skeletal meshes being updated also contributes to the cost as well when dealing with large numbers of characters. Skeletal meshes being more expensive than static. I think I read somewhere that the Total Battle War Simulator or whatever it is called did kind of a hacked version of instanced static meshes in unity where instead of interpolated animations it's just a bunch of instances cycling through a bunch of static models that are swapped out to give the illusion of animation, sort of like stop-motion, which is why when the game is in "slow-mo" the animations don't seem smooth even at a high frame rate. The current penultimate solution for thousands of animated meshes would be skinned mesh instancing, which Nvidia released tech docs on, although that's currently not a built-in feature of the engine.

                            Although from the little I've seen from your blueprints, I'd honestly recommend going through Epic's video tutorial series on youtube (multiple free hour long presentations on things such as AI where they guide you through it). They have a pretty good series that could help you understand Epic's practices with their currently-implemented solutions to AI such as how to use behavior trees. I'm pretty sure the AI-move to for example, only needs to be called once per action/destination, not multiple times every frame. When it comes to AI, it might be best to think of things in terms of functions, and triggers / Causes and Effects. Generally speaking and as a simplified example, it's much better to say, call a function that does damage to an AI when it enters a context OnOverlap Event, instead of checking and telling the character to do something all the time per tick/frame.
                            Indie Dev - Whiskey Cat Softworks
                            Currently developing a colony survival game!

                            https://twitter.com/WSoftworks https://www.facebook.com/WhiskeyCatSoftworks/

                            Comment

                            Working...
                            X