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

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 ?

yeah i get what you are saying … and this would be just too complicated … ok so i will have like the main area … and you can go through doors . when you finish you will be back to that main area to continue … i think that’s it … i will try it out … build something … and see what’s going to happen … and will let you know if something comes up … thank you so much for helping out … i don’t know if i told you . but your name will be in credits if i ever finish this game of course lol … really thank you for the time you give to help people like me . seriously it means a lot .

going to test and tell you the results . maybe even post a small test to try it out .

It does work if you pause the scene and go to the next and then use the Stop and go back to previous event at the second scene, but the second scene will be not paused. So you can not move back and forth between the scenes and I believe it is because only 1 scene can be paused by design. So when you pause the second scene and go back to the first scene, what is happening, because you paused the second scene, the first scene get deleted from memory and get loaded again that is why it start from the beginning when you try to pause both scenes when you switch. It seems to be not possible to pause both, only one at the time.

You mean saving and loading? It is not that complicated really and you do want to save the game at some point don’t you? So you need to implement it anyway.
I can help you with the save/load system if you want. I mean for free but I’m going to need your project with all images so I can run it and test it. And the list of things you want to save and load.

yeah i have save/load ready and working … i mean if you have to save everything in a scene (you take / you kill) so when you get back it stays the same as you left it .
now i have only one paused scene i can back to … and it’s still awesome.
but if we found a way to make the player go back and forth … just imagine what i can do in this game … the level would feel like a small open world … it will encourage you to explore . stuff like that … but now all i have to do is just keep the player move forward … always move forward and never come back to the place he was in because you know it’s not paused/saved … i can make him go back only to the paused scene .

if you can find a way for that to happen … just omg it would be amazing
sorry if i sound super excited but i just love this … and i’m ready to make something really amazing . but only if this is possible “BACK AND FORTH” . but i can still make it fun with what i have .

i don’t know if you know a game called “Hollow knight” ?
i love this game … if you take a closer look you’ll see that the world is basically a punch of parts you go through … but even in this game the scenes don’t pause or save when you go back and forth . but that’s for another reason which is they need you to collect coins for money so you can buy stuff so when you go back you find the same monsters . you kill them again to collect some more coins . BUT . the secrets you collect are saved when you go back and forth “that’s what i’m trying to do”
but i know if they want to make the game save scenes when they go back and forth … they would do it .

There has to be a way in GD5 … i hope at least .
And if not … i just hope they implement it very soon :frowning:

Could you test it please on a new project with like 2 scenes . just maybe you’ll find something at your side ?
i have been just testing like crazy yesterday but never did it .

Waiting for any hope for this .
Anyway the first working test of the game … i will post it here so you can test it too and tell me what you think about the performance and stuff like that . maybe tonight or tomorrow .

It’s simple, just save the info into a variable, then either export it into a json; then you read them once a scene starts therefore when you populate the gems / enemies it will base off that, than just a static way of rendering / map making, you can also check whether an entity is on the screen before showing them to reduce the lag.

This is the only way to do it. You do need to save everything. I mean what if the player quit the game? You do want to save everything don’t you? If you have the save/load already in place just use that…

In case you would be making an open-world imagine that at level4 the player quit the game then tomorrow go back want to start where finished last time but then want to go back to level1 and expect everything to be as left. In an open-world at least. The only way to do this is through save everything permanently but GDevelop dos not do this for you automatically. You need to set this up manually using the Storage actions.

Storage action can take care of all this and write everything in to web storage directly, no need json and variables for saving

Storage action…Using the Storage action, Write everything in to web storage at the end of each scene or whenever you want and Read everything from web storage at the beginning… If you have the Save/Load already in place just use it…