• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

[SOLVED]Quick Persistence Question

I don't know if this is a persistence issue or frankly what the problem is. The game starts and you drop a bat down to the playing field. So everything is normal and configured and there is a brain that is produced. It works as supposed to. However, when I leave the game room into another room, say the store, and return to it the brain enemy vanishes. The player's bats are still on the playing field just like they were when we entered the room.

The game room is set to persistent. The store is not persistent. The bat is persistent. The brain is persistent.
I know there is a difference between room persistence and object persistence.Just not sure what is applicable.
 

samspade

Member
I don't know if this is a persistence issue or frankly what the problem is. The game starts and you drop a bat down to the playing field. So everything is normal and configured and there is a brain that is produced. It works as supposed to. However, when I leave the game room into another room, say the store, and return to it the brain enemy vanishes. The player's bats are still on the playing field just like they were when we entered the room.

The game room is set to persistent. The store is not persistent. The bat is persistent. The brain is persistent.
I know there is a difference between room persistence and object persistence.Just not sure what is applicable.
Not sure off of the top of my head as I try to avoid this type of persistence (where persistence is used to save things). That said, my guess is the debugger could answer this question fairly easily. Put in break points and enable real time debugging and see which instances exist and where.
 

rIKmAN

Member
I don't know if this is a persistence issue or frankly what the problem is. The game starts and you drop a bat down to the playing field. So everything is normal and configured and there is a brain that is produced. It works as supposed to. However, when I leave the game room into another room, say the store, and return to it the brain enemy vanishes. The player's bats are still on the playing field just like they were when we entered the room.

The game room is set to persistent. The store is not persistent. The bat is persistent. The brain is persistent.
I know there is a difference between room persistence and object persistence.Just not sure what is applicable.
This sounds like a bug that is already logged on Mantis where persistent objects get their layer set to -1 upon returning to the original room.
It can be worked around by checking / setting the layers in code, which you probably would have seen if you used the debugger to check what is going on with the missing instances

Here are a couple of good tutorials / guides on using the debugger, which will help you massively going forward as the better you understand how to use it the quicker you will be able to debug your projects and pinpoint problems that you are having.

Debugging with GMS2
Advanced Debugging and Profiling in GMS2
 
Well I ran the debugger in profiler and it says the brain (SimpleBrain) is still there after I return to the room. Take a look:

upload_2019-4-4_0-37-12.png

So thinking it was that bug posted about, I set the SimpleBrain's depth to -18000 w hen it leaves the room. Still, no dice.
 
Last edited by a moderator:
This sounds like a bug that is already logged on Mantis where persistent objects get their layer set to -1 upon returning to the original room.
It can be worked around by checking / setting the layers in code, which you probably would have seen if you used the debugger to check what is going on with the missing instances

Here are a couple of good tutorials / guides on using the debugger, which will help you massively going forward as the better you understand how to use it the quicker you will be able to debug your projects and pinpoint problems that you are having.

Debugging with GMS2
Advanced Debugging and Profiling in GMS2
What do you mean worked around by checking/setting the layers in code? It looks to me like the instance isn't missing according to the debugger (see above).
 

rIKmAN

Member
What do you mean worked around by checking/setting the layers in code?
I mean check the objects layer when it disappears and if it has been reset to -1 like the bug I linked to then set it back to the layer you want it on.

Your issue might be unrelated to the bug, but it sounds like your problem is similar enough to warrant you looking into it.
 
Last edited:

samspade

Member
You've only gone part of the way to solving it at this point. As rlKmAN said, first look at the layer, but now that you know the object is in the room, look at everything else about it. What is its position for example? It's image scale, alpha, anything that could effect whether or not you can see it.
 
Ok Samspade, I think I understand all the windows in the debugger for the most part. However, i don't know how to use the instances and variables portion.
Also you said about checking the layer for the simple brain. Am I to do that in the debugger? If so, where? In the profiler? I looked in the profiler and under SImple Brain
there isn't a layers sections.

Thanks :)

TW
 
Last edited by a moderator:

samspade

Member
Ok Samspade, I think I understand all the windows in the debugger for the most part. However, i don't know how to use the instances and variables portion.
Also you said about checking the layer for the simple brain. Am I to do that in the debugger? If so, where? In the profiler? I looked in the profiler and under SImple Brain
there isn't a layers sections.

Thanks :)

TW
The layer and all other built in variables are under the instances tab (and a few others but that's the easiest to find) then under that instance, then under built in variables. That would be the easiest way. Since you know it exists you could also put a show_debug message in room start to see what it says.
 

samspade

Member
@samspade Instances tab is empty for some reason?
Not sure. Is real time debugging enabled? Have you paused it, used break points etc? Have you checked to make sure the various tabs are correct (you can move and close the sections within tabs). It's probably down to some setting or action you've set up perhaps without realizing it so unlikely we can debug unless we get lucky as to what it was. I'd just experiment, read up on the debugger and try different things.
 
F

FB-Productions

Guest
I don't know if this is a persistence issue or frankly what the problem is. The game starts and you drop a bat down to the playing field. So everything is normal and configured and there is a brain that is produced. It works as supposed to. However, when I leave the game room into another room, say the store, and return to it the brain enemy vanishes. The player's bats are still on the playing field just like they were when we entered the room.

The game room is set to persistent. The store is not persistent. The bat is persistent. The brain is persistent.
I know there is a difference between room persistence and object persistence.Just not sure what is applicable.
Just so you know in the future: room persistence saves the entire state of the room, so that it can continue running from the point it was like when you last left it.

Object persistence, on the other hand, makes all instances of that object persistent (if you use the checkbox to mark it as persistent), which means that they will travel from room to room without getting destroyed automatically (normally you lose every object in from a room you leave, but persistent ones remain in the next room/s aswell).
 
@FB-Productions In this case I don't want object persistence on the simple brain, cause I don't want to have him carry over to the next room, right? So just room persistence should be sufficient because I want the state of the grasslands room to be saved when I go to , for example, the alchemist's laboratory, and then return to the grassland's level.
 
F

FB-Productions

Guest
@FB-Productions In this case I don't want object persistence on the simple brain, cause I don't want to have him carry over to the next room, right? So just room persistence should be sufficient because I want the state of the grasslands room to be saved when I go to , for example, the alchemist's laboratory, and then return to the grassland's level.
Sorry, I didn't fully read your first post because I thought the other members solved the issue. :D

But, yes, any object you don't want to be carried over to the alchemist's laboratory room should be left normal (UNpersistent).
So, keep persistence OFF for the simple brain.
As for those who need to be carried over, those need to be persistent.
(There is also a variable (persistent = true or false) for you to set the persistance of a single instance (instead of an object with all its instances).)

As for rooms, I don't know exaclty how your game is supposed to work.
But if you want both your rooms' changes to be memorised, then they should BOTH be persistent.
If not, then just the one that you want to return to (the Grasslands) should be persistent (so it can be unpaused from its last state).

:)
 
Sorry, I didn't fully read your first post because I thought the other members solved the issue. :D

But, yes, any object you don't want to be carried over to the alchemist's laboratory room should be left normal (UNpersistent).
So, keep persistence OFF for the simple brain.
As for those who need to be carried over, those need to be persistent.
Question though. If I turn off persistence for the simple brain, it won't be carried over to the alchemist's laboratory so if I do so and spawn a brain, go to the alchemist lab, and come back willl the simple brain still be there?
 
So I played around with the settings and now it works. Thanks. I made it so the characters weren't persistent and the rooms were. Seems to have worked. Thanks!
 
F

FB-Productions

Guest
Question though. If I turn off persistence for the simple brain, it won't be carried over to the alchemist's laboratory so if I do so and spawn a brain, go to the alchemist lab, and come back willl the simple brain still be there?
If you create the brain (NOT persistent) in the Grasslands (persistent ROOM) and go to the Lab room, the brain won't be there. But, when you go back to Grasslands, the brain will be there again.

So I played around with the settings and now it works. Thanks. I made it so the characters weren't persistent and the rooms were. Seems to have worked. Thanks!
You're welcome! :)
 
Top