Ask here your questions to get help using GDevelop.
By Rex
#60681 How do i keep the game run smoothly with no lag? Is it possible to keep the objects like particles and light inactive to reduce the lag?
User avatar
By ddabrahim
#60691 Generally, you need to make sure you trigger events only when needed and only as many times as needed.
For example:

When you check collision, you may need to consider to use a timer and check collision only every 0.2 seconds, this way the collision check is going to be triggered only 5 times a second instead of 30 or 60.
Also, try to avoid using pixel perfect collision checking as it is extremely resource hungry. For the most part, collision shapes and simple shapes should work just fine but in case you need a complex shape try to use few polygons only, the less is better.

Avoid using multiple conditions in the same event, try to brake up the conditions in to sub events instead. For example if you want to create a button that can be clicked and you want to do something when it is clicked:

Code: Select allEvent: If Left mouse is pressed
-sub_event: mouse is over button : do something


In this example, if the mouse is over the button is going to be checked only if the mouse is pressed, this way you don't waste resources on checking if the mouse is over the button even if it don't even need to be checked (the mouse is not pressed).

In case you are deleting, creating objects on the fly, before trigger any events on those objects, check if there is any objects in the scene at all. For example, bullet. Before try to move a bullet and check collision with a bullet, make sure there is any bullet in the scene.

Code: Select allEvent: if number of Bullet is > 0
-sub_event: bullet is in collision with enemy
--sub_event: Do - 10 to health of enemy
             health of enemy <= 0 then delete enemy


It a complete waste of resources to try to check conditions on something that don't even exist. In case something can be deleted from the scene or created on the fly, always check if there is any in the scene before doing anything to them, with them.

Finally, it always a good practice do not use huge images in your game. Instead of scaling down too big images, always make them to be just the right size to fit the game.

This is all I can think of right now but I need to admit, even with all these techniques I have never been able to make a smooth experience in GDevelop. From my experience even if you just try to move an object in GDevelop, sometime it lags without doing anything else, but move. I do experience it on both HTML5 and native and even in the game 4ian is making, so I'm pretty sure there must be a problem in GD somewhere but I'm not an expert on this topic maybe I'm just overlook something but it a fact, every now and then someone always show up with weird lag problem, maybe this time it you and everything I have suggested you have already tried.

4ian has mentioned this year he is going to pay more attention on performance improvement and he would like to finish the game he is making so I really hope this mysterious lags that people experience time to time going to be solved, until then you can try to make to most out of it with my suggestions and hopefully others may going to have a few more tips as well. Actually I would be also interested to hear some thoughts on this topic.
Last edited by ddabrahim on Tue 10 Jan 2017, 23:40, edited 3 times in total.
User avatar
By victor
#60692
I do experience it on both HTML5 and native and even in the game 4ian is making, so I'm pretty sure there must be a problem in GD somewhere but I'm not an expert on this topic maybe I'm just overlook something but it a fact, every now and then someone always show up with weird lag problem, maybe this time it you and everything I have suggested you have already tried.


Are you sure it's not just that you didn't enable Vsync (for native games at least), it could be the cause of those mysterious apparent "jumps" when objects are moving. They are not a lot of things to improve in the native games, and nothing should cause random FPS drop.
User avatar
By ddabrahim
#60693
Are you sure it's not just that you didn't enable Vsync

Yes I'm sure, Vsync is enabled. I'm wondering if it could be related to graphics driver because with my old GT430 I did not experienced lag, I do experience the lag since I have upgraded my graphics to GTX750 Ti. Also it doesn't seem to be the same for everyone. Some people do experience the lag while others don't or under different circumstances.
By KiEN
#60707 Although I'm sure there's a lot to optimize within my game, I've been able to run the most resource-heavy AAA games on my computer, so there has to be a bug or a compatibility issue with the newer machines.

I love GDevelop and if the lag issues could be fixed it would be perfect for my needs.