Problem with rendering

0 favourites
  • 12 posts
  • I have this problem with the rendering of my game and I am unsure whether I should continue working on the project, since I can't find a solution for it for quite a while.

    My CPU is over 50-70%, which means the code of my project is fine, but on mobile devices (and rarely on my PC) the FPS drops below the minimum 30 half of the time and the movements in my game go into slow-motion. I've tried setting the minimum framerate to less than that, but then I would experience issues like objects teleporting through other objects that are about to stop their movement....

    I have read some tutorials about rendering and WebGL, and I couldn't find anything that is wrong with my project.

    This happens in the 'Level' layout of my project.

    The levels contain objects that are placed in a grid, and 70% of these objects are instances of 1 object type with 2 different textures (2 animation frames). I can't make a tiled background or something since the position of objects differs in each level.

    The trees and rocks objects in the image are actually of the same object type but different animation frames.

    So, the problem occurs when I move the player. He never walks as fast as he should do, and sometimes he walks even slower.

    I don't know how much info do I need to provide because the game is very simple as far as I think.

    Have you ever encountered a problem like this, and how did you manage to solve it?

  • Hi,

    With such a simple game there should not be the problems which you describe. This means there is a flaw in your design which forces the game to use a lot more resources than it should.

    Look for especially object creation and destruction.

    RE: Creation

    Often if you have not specified TRIGGER ONLY ONCE there are a million objects created in seconds (even if you don't visually see it).

    RE: Destruction

    Make sure you destroy every objects when its time has come. Either via FADE behavior or via EVENTS Destroy Object. If you don't destroy then you will start having unlimited objects flying all over the place.

    Lastly,

    Play your game using the DEBUG PLAY button and not the PLAY button and watch very carefully at the bottom the number of objects and other things that eat memory.

    Good luck

  • Hi, thanks for the reply.

    As I said above, my events are fine. The CPU will reach 100% if I am creating my objects every second and will possibly crash the game.

    All of the objects are created at the start of the layout and 90% of them are never destroyed.

    Also, it is good to note that my images are not bigger than they should be, which may be a cause for my problem...

  • You are doing something wrong and that's a fact. I've recently published a game( which you can check on the arcade) and its only using 15mb ram and 5-10% CPU usage.

    Its not the engine fault or rending fault. Slow FPS can be tracked in the logic or the graphics of the game. If the images/spires ware to big then the ram usage would be huge, 2000x2000x single image spire takes 16mb of ram. If your cpu usage Is high and ram usage is low it means that your logic is flawed, it can be caused by lot of collision check, to many physics calculations, to many enemies/players with light of sight or patch finding behavior, or to many loops in the events etc.

    What's the best solution? Learn how to use the debug more and check where the cpu usage is going, the debug shows every event and how much CPU they are using, I've seen lots of big games made with construct like whole RPG's with lots of elements and stuff and they did not lag at all, and besides if you don't learn how to optimize your games no one will do it for you, the machines are not perfect you can make a game with 2 sprites and have it lag on the best computers out there if the optimization is bad.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I have checked all those stuff. I have reduced collision checks to over 200 per tick. There's bo line of sight or physics in my project.

    I know how to use the debugger, the CPU is never higher than 30% ( while the max on a mobile is 70%, but it is mostly around 60%).

    I have 300-400 objects in each level. I can't go below that, but I've tried removing some of them and tested the game with around 170 objects. It still lagged and there was np difference. The objects I have removed were not moving either way.

    The only object that is moving is the player, and a few other animating objects.

    I wouldn't create this thread if I haven't read thousands of tutorials about optimizing and all that stuff....

  • How many animated objects you have? and how many times per tick they animate? Also if you have images larger then 300x300 px try to reduce their size, in the debugger how much % goes on draw calls?

    You know just make some screenshots (the system, cpu and ram usage) in debug and post them here, so we can have a look, like this I can only guess.

  • when the player is idle

    when he's moving

    again when moving, but this time you can see the draw calls and engine...

    The largest images in the layout are over 41x58 (maybe it's small, but I had to try and minimize them and test the difference)

    And there's also the image of the UI 100x550. I can't make this one smaller....

    There's over 10-15 animated objects in each level. They change frames every 0.12 sec..

  • The collision checks are okay, the image size is also fine.

    But you are engine and draws calls are really high in CPU using, and that's just CPU alone if we take the GPU into account it will be probably even worse. I did a comparison with the games worked on and made, and all of them take around 1% for draw calls and between 0.5-1% engine.

    Your problem can be caused by those two, high draw calls means the engine is trying to render a lot of spires at once, and if those images are also animation that can cause even further problems. You can improve this by reducing the resolution size of the game so less objects can be viewed at once, also if you spawn new objects on the layout while the game is running or using particle effects try to minimize that, instead of creating the objects on layout create them while its loading and then teleport them where they need to be.

    On the second picture you showed where the player is moving they are two event groups that take 14% of CPU power, which ones are those, I was unable to identify them from the picture? You can also try to tweak those because 2x14 is around 28% usage which is high.

    And now for the engine usage, the engine usage in the debugger is only for the behavior and some other c2 stuff, which means if you have high usage is probably caused by same behavior, I don't know which one, but some of the is using a lot of CPU, you will have to figure that out, make a back up copy of the game and start deleting the behaviors and see which one improves the performance.

  • Well one quick check to see if it is rendering the issue would be to change the quaity of the rendering (fullscreen scaling) to low and test (it's a project property that is on high by default, more infos in the manual but basically it will not scale up the game assets if needed which should improve the perfs if it is indeed GPU bottlenecked)

    I'm not sure it's caused by it but I'll ask anyway: why not use a tilemap for the ground? you can set it up to be different each level.

    It's very weird though, as it seems simple ad so I don't see why it operates poorly, how are you testing on mobile too?

  • The collision checks are okay, the image size is also fine.

    But you are engine and draws calls are really high in CPU using, and that's just CPU alone if we take the GPU into account it will be probably even worse. I did a comparison with the games worked on and made, and all of them take around 1% for draw calls and between 0.5-1% engine.

    Your problem can be caused by those two, high draw calls means the engine is trying to render a lot of spires at once, and if those images are also animation that can cause even further problems. You can improve this by reducing the resolution size of the game so less objects can be viewed at once, also if you spawn new objects on the layout while the game is running or using particle effects try to minimize that, instead of creating the objects on layout create them while its loading and then teleport them where they need to be.

    On the second picture you showed where the player is moving they are two event groups that take 14% of CPU power, which ones are those, I was unable to identify them from the picture? You can also try to tweak those because 2x14 is around 28% usage which is high.

    And now for the engine usage, the engine usage in the debugger is only for the behavior and some other c2 stuff, which means if you have high usage is probably caused by same behavior, I don't know which one, but some of the is using a lot of CPU, you will have to figure that out, make a back up copy of the game and start deleting the behaviors and see which one improves the performance.

    Hi, thanks for the reply,

    First, the CPU usage for these two event sheets is rarely that high, it is usually around 3-6%, but sometimes random events just appear with some crazy value and then they are back to normal again, so it's not that high as it is in the second picture.

    As for the engine, yes, it is really high, sometimes it gets up to 22%. If it is a behavior the problem, then the first suspect would be 'CustomMovement', because the engine's CPU raises only when I move the player.

    'CustomMovement', 'DestroyOutsideLayout' and 'Pin' are the only behaviours in my project (however 'pin' is very rarely used in this layout).

    Well one quick check to see if it is rendering the issue would be to change the quaity of the rendering (fullscreen scaling) to low and test (it's a project property that is on high by default, more infos in the manual but basically it will not scale up the game assets if needed which should improve the perfs if it is indeed GPU bottlenecked)

    I'm not sure it's caused by it but I'll ask anyway: why not use a tilemap for the ground? you can set it up to be different each level.

    It's very weird though, as it seems simple ad so I don't see why it operates poorly, how are you testing on mobile too?

    Hi, thanks for your reply,

    I have set the 'Fulscreen Scalling' to No as you said, so it didn't make much difference in the graphics (since I've also set 'Sampling' to 'Point') and I need to test this out on a mobile, because my problem is harder to notice on a PC.

    As for the ground, I am not really experienced with tilemaps (or I would say, I'm a noob), but I also think it won't make much difference. Another thing that I should note is that the image of the 'Tiled Background' is 250x250. I can't make it smaller, it needs to be the same size as my grid. But I doubt that the image size is the problem here.

    edit: I have tested the game with 'fullscreen scalling' to no, but there is no difference.. :/

  • The custom movement can maybe be the problem then, you can do a quick test disable the behavior and all the events and run the game and compare the results.

  • But then I will never know if 'CustomMovement' is the problem. Because I can't move the player without this behaviour.

    I have created my own moving system, but that system was very inefficient for my CPU, it would pass beyond 200% once I issue the player to move, and then go back to normal but it surely caused a lot of lag. This is because, every few sec I had to move the player a bit and check if his XY is the same of some objects that are on his path (I calculate the path and the XY of the objects on it before I call the move function).

    So, I realized this system is even more inefficient and it has a lot of improvisation in it, so I have returned to my 'CustomMovement'..

    So, if this behavior is the problem, then maybe I am doing something wrong with it?

    Here's a picture but I doubt it would help. I really have no idea what may be wrong with this behavior...

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)