Do object timers work throughout multiple scene?
If i am correct it doesn’t
So how can i use object timer throughout scene without resetting it?
Hi, there is this workaround by DX_studios1 for a global scene-timer, but it should also work for an object timer:
Okay so i tried it and i am encountering a problem is that it is not working together for multiple instances
is it possible to use global variable for multiple instances?
If you have several instances, each with their own timer, than you would need to create a global variable for every single one of them.
Depending on the number of objects this could be quite tedious, but the given solution is as mentioned just a workaround.
The thing is player can create multiple instances with no limit
that is why i tried object timer but i don’t know how to take it through scenes
I see. You could consider to use external layouts for different levels or parts of your game instead of different scenes. In this case the object timers wouldn’t be affected.
https://wiki.gdevelop.io/gdevelop5/interface/scene-editor/external-layouts/
Scenes are important for the game i am working on
If i make external event for the timer and use it i think it still won’t carry the timer value?
That’s right. The idea would be to have just one scene in which you load your external layouts which would contain the layout of the world/level that you actually want to go to by changing the scene. In that case you don’t change your base scene and that’s why the object timers would work.
But putting the entire map and the scene levels/rooms wouldn’t that be bad for the performance?
I have tried it and i had to change to use scenes and now i have to have timers for each instances of objects that will be deleted after certain amount of time doesn’t matter on which scene the player is
If i give variables to objects then can it be loaded through out the scenes?
You could load the external layout just when you need it. Instead of changing the scene, you load the external layout. After you get out of this part of your game, you can delete the objects that were in the external layout and load another one. (There is no ‘delete external layout’-action, but you can put all the objects of an external layout in a group and just delete the group.
You need global variables for that, which brings you back to the solution of DX_studios1. The value of an object variable is not carrying over to another scene (even if it is a global object).
So if i save object variables into global variable and then transfer it to another scene and then transfer it to the objects
then maybe it will work
Yes, that will work. The tricky thing is that you can get the timer value of your object into a variable but you cannot pass a variable into a timer (for example to tell the timer from which value it should start to run). That’s why you would need the above mentioned workaround for every object that runs a timer.
hmm Okay i have a question does having many layer on a scene causes lag?
most likely yes
and because i have lots of UI for objects and even npc houses are accessible so can 1 scene really handle all that?
You have to see how things work for you. I am not sure whether the number of layers has an impact on performance. If you use effects on them, then certainly yes.
I remember that in the past having a lot of scenes would slow down the performance - that’s not the case any more! - and an alternative was to load the levels/worlds/stages with external layouts into a main scene. So depending how things are set up it may work, but it really depends on all the details in your game.