Is there a way to enable V-sync in gdevelop 5 ?

The title …

Thanks for helping .

Anyone ?

Hmm as far as i know it is automatically handled on GD5. May I ask why btw? is the game running slow on your end or something? or wanna limit it to a certain frame rate like how you could on GD4? If that is so maybe base off your animation speed and time scale / game speed to the desirec computation amount.

Rikazu Yeah my game is a bit slow/ laggy … ok so how do i do that ? I mean if i changed the time scale of the game … it will be a slow motion right ?

You run your game on android right? Since the way how GD handle android and other platforms is that it runs the web build to it and uses a packer like cordova (android) to open it / run it; so it’s a hybrid and not a native one so it will never get the whole potential of the device, probably can do is to lessen the objects on the current scene and make them appear on the other; but still depends; Have you tried checking stuff on the performance profiler? I haven’t had that much lag when testing mine, and it has 5k+ objects.

Rikazu On Android yeah
I’m sorry i don’t get what you’re saying here ? What do you mean and how to do it ?

(probably can do is to lessen the objects on the current scene and make them appear on the other)

It’s not lag but you can say when the player moves … the game feels like it’s loading the objects in the level … once loaded . It stays smooth . So how to make it load all the objects once the game starts ? How to keep it smooth ?

Oh btw . How to check the performance ? I’m sorry I haven’t checked that before so i don’t know how .

Objects on a scene are automatically loaded to the memory, once a scene starts. So that may not be the case, you need to lessen the objects in a scene.

You can also try the “always load in memory” option if you still think of that scenario, Game Settings > Resources > [Select the image / resource then tick the Always loaded in memory option]

Just run debug, don’t you even do that when making a game?
Debug > Performance Profiler

Rikazu I have done that “always loaded in memory” and the performace got much better but not the best you know ?
The micro lag/stutter is so annoying at points
It’s my first game so yeah i heard about the debug but never actually used it or look what it’s inside … i’ll check it out once i get back home and understand it better .

Btw i have so many objects … could reach like 300 or more in one scene … could that be it ? And if so … is there a way to keep that amount of objects in the scene without losing performance ?
Most pictures are 3232
Some are 16
16

Also How can i make a loading screen ?

Thanks for helping …

yeah it would be nice if you could divide them up to other scenes, since this is your first game it would be a good practice (in my opinion). but I have tested having 2k+ object in a scene and it doesn’t have much of a performance problem, ALTHOUGH that was on desktop, since the one i am talking about, on mobile is that; the way GD handles it is a hybrid approach, means that it uses the webview / third part handlers like cordova, phonegap and etc to handle it, it will not be as good as the native approach for it’s performance. You can handle / make a loading screen by having it at the beginning of a scene that you wanted to show it before.

Rikazu Yup on desktop it’s perfect no matter how high quality the pics used in the project i have tested it too … but in android … i think it’s a lot weaker .
Ok so my game has levels … each level is big .
How do you think i can devide a single level into parts ? Like different cameras maybe.
It has to be in one scene though .

Is it okay for you to share the current apk of your game? I would like to test it on my device.

Rikazu yeah here you go .
You can try level 1

The thing is it will lag on your side because there is no loading screen in the file i uploaded. Because i can’t upload a file bigger than 3 mb

Yesterday i made a loading screen with all the objects so when the geme starts the whole game loads in … and it worked … this eliminated 80% of the stutter … still not perfect . But much better .

So test it out for you know just testing … maybe tell me what you think about the game . What you like and what you don’t . The controls … stuff like that . That will truly help a lot .

Also if you know a simple way to make the monsters AI better ? that would be great

Hope you like it . And also i hope it runs smooth on your device .

Waiting for your response :slight_smile:
game apk file.zip (2.68 MB)

Did you try to remove the enemies and see if it helps?
If it does, what I would recommend to do is whatever the enemy is doing, moving, attacking player, playing animation…etc do it only if it distance from the player is below a certain amount, in other words update the enemies only if they are on the screen. Otherwise you are only waste resources on them.

If it doesn’t help, try the gems too. In case removing the gems does improve performance, then try the same thing and update gems only if they are at certain distance from the player / it on the screen. Otherwise it is useless to update their animation and run the events to check collision with player and what not. Alternative to collision, you can also try checking distance only instead of collision. Collision checking does use more resources than distance checking but many times checking the distance is enough, no need collision checking.

Same goes for physics, easy to make staff move with physics, but in many cases all you want is increase and decrease position. So you also want to consider to simply update position of objects whenever you can instead of using physics to apply a force to make something move.

Also, in case an object doesn’t really interact with anything, and you have many next to each other, always consider using the tiled sprite, or a single image with multiple sprites on it to reduce the number of objects in the scene.

You can also reduce the number of objects in the scene by using external layouts. As the player moving forward, you can delete anything that is behind the player and create from external layout everything in-front of the player. This way, you can minimize the number of objects in the scene at any given time regardless how big the level is. It is something I never tried actually, creating and deleting objects constantly can be expensive but in case the number of objects causing the lag, it would be a way to reduce the number of objects without changing between lot of scenes and without need to reduce the size of the levels. It would also allow you to make levels randomly generated, if interested. Though, in case constantly deleting objects behind the player and creating new ones in-front would be too heavy task, then what you could try is do it only once in a while and display a “loading…” message for the player and make it wait until the rest of the level get loaded and last part get deleted sort of like in a sandbox game where you have a loading screen when you enter different areas of the world. Maybe call it “checkpoint” and also save the state of the game there and then the players would more likely accept it if they need to wait a moment once in a while…

Finally, in case what I was suggesting doesn’t help at all, the last thing I can recommend is try Cocoon with Canvas+ to package your game. It gives you almost native performance with HTML5.

Regarding the game, looks and apart from the lag it feels good. I think you should share it for desktop too (without the touch controls). I did experienced some weird bug with the touch controls but not sure if it caused by the lag or something else. Once you have the performance improved would try it again.

ddabrahim Thank you so much for the help … so i’m trying the solution where the rest of the map gets loaded in from an external layout then what’s behind the player gets deleted …
But i don’t know how you can delete objects behind the player ??

Create a group and call it, AllObjects or something and add all the objects to the group that you want to delete. An then check if the X position of AllObjects (the group) is less than the current X position of the player, and the distance of AllObjects is greater than say 300 pixels then delete AllObjects. It is going to apply to all objects inside the group that is meet the conditions.

The actual event could look something like this:

But keep that in mind, as I mentioned it may also going to have negative effect on performance as you are constantly looping through all objects and check their position and distance against the player and delete them, especially if you are also going to create objects form external layout the same time. So you may want to do this only once in a while. Maybe divide your current level in to 2 or 3 parts (external layouts) and then do this only once or twice in a level.

But actually, it may be just overcomplicating things really. I can’t think of any benefit to do it this way other than you can randomly generate levels if you want. In case you don’t want to randomly generate levels, you could just simply divide each level in to multiple scenes and switch between them like Level1_1, Level1_2, Level2_1, Level2_2 for example. It would be a lot easier I guess :laughing:

ddabrahim yup that’s what i was thinking too but i thought just to try that out … and i did … it was better not gonna lie … but not great in anyway … so what i’m doing now is like you said … splitting 1 level into different scenes … and this could actually work but i have a huge problem now …
How can i keep scene var. like “score” just keep the number of gems collected . enemies killed … stuff like that … when i go to the next scene ?
because that’s the core game play and that’s how you progress

this could actually work finally … i haven’t slept for basically 24 hours … so tired :laughing: … but i know i can make it smooth . waiting for your response because this could be it finally … this will allow me to be able create honestly some big levels … even open world … this will be awesome … only if could keep the important scene var. with me … which is …

1- gems collected
2- hearts “health”
3- ammo
4- enemies killed “number of enemies killed”

if i have those for the specific level “scenes combined for this level” … i can make this game happen and i can make it really good too . so excited but so tired LOL … waiting for a response .

Make all those variables global variables and it should be available to you from any scene as long the game is running.
You can also use storage actions to write the values in to storage at the end of the scene and read it at the beginning as you prefer. Some sort of save/load system going to be required in your game anyway, so this is what I would personally do.

it worked but i have another problem .
i need to be able to go between scenes back and forth so i did .
when player is in collision with “teleport”
pause the scene and go to the next scene
when i’m in the next scene …
when player is in collision with “teleport”
pause and go back to the previous paused scene

but when i go back it starts from the beginning … the scene just restarts …
so how to keep it paused when i left for another scene and when i come back … everything stays the same in that paused scene ?

I never used this feature to be honest.
However I believe only 1 scene can be paused at the time. It is meant to be used in cases for example when you want to start a bonus game, then you can just pause the scene, start a new scene with a bonus game then go back to the paused scene. It is not meant to be used like you want it, to avoid people having too many paused scenes in memory.

You can easily create your own save and load system to work around this. Take a look at the save/load example.

ok i did it but it only goes back to the previous scene … i need to be able to go back and forth and everything just keeps the same ? can i do that ?