GameMaker Missing layers in room on load

Hey guys! This is my first post! I have got a GMS licence few weeks ago because i think is easy and nice to develop retro games, so i love it! But i'm having issues recently! I have read ALL my codes and everything is fine and i suspected about layers missing on load randomly! Look, i got room calls level_1,level_2 and so on for my mission worlds, OK! But my main characters starts to float up and this is beacuse thhe gravity script, and it is ok because when every thing is OK my character stands on ground perfectly! But when bug happens my character starts float up as i mentioned!

Well, i wrote and script on create event of my camera follow object to check if layers were created, in this case, my solid tiles and platform tiles layers, i wrote something like this in pseudocoding

layersfound = false
while(!layersfound){
if(layer1 && layer2){
layersfound=true;​
}
//this push my program stacks here if layers i need never were created! when bug has not happened this //just find the layers and go out this while loop and game keep working fine, but when bug happens, the //script stacks in this loop confirming that i was right, layers are missing on room load!!​
}

I hope you can understand my english so badly! xD hehehehe

Have a great development boys!!!
 
We need to see the ACTUAL code... ;)
no coding affecting this! i have not made any code to manage layers, just reading them, in my mission rooms i got two layers, 1 SolidTiles (Solid places that cannot be passed throught) - 2 PlatformTiles (ground bars than can be passed throught)

i got 3 levels in my demo, and sometimes in level 1, 2 or 3 (randomly) these layers disappear, i thought layers Solid and PlatformTiles had not been created in these cases, so i wrote a code to check if layers exists when this bug happen and i got positive confirmation! Bug happens (player floating up) because layers (Solid and PlatformTiles) were not created! Reason?? I don't have idea why! Because sometimes my game runs well and meh! it happened again! (when room is loaded)

Why a room can load randomly delete certain layers? Any memory, cache reading problem?
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
Okay.... well, in my experience layers don't generally "just disappear" and if that was the case then many more people would be posting with the issue... which means I have to ask:

Do you have anything in your game that could be removing the layers?
Have you tried cleaning the compiler cache before running (a stale cache can often cause weird errors like this)?
Is it only tile layers that are affected by this?

Also, as a check, a better code would be something like this:

Code:
var _layer = layer_get_all();
for (var i = 0; i < array_length_1d(_layer); ++i;)
{
show_debug_message("Layer " + layer_get_name(_layer[i]) + " exists!!!!");
var _element = layer_get_all_elements(_layer[i])
for (j = 0; j < array_length_1d(_element); ++j;)
    {
    switch (layer_get_element_type(_element[j]))
        {
        case layerelementtype_sprite: show_debug_message(">>>>> layer has sprite element");
        case layerelementtype_background: show_debug_message(">>>>> layer has background element");
        case layerelementtype_instance: show_debug_message(">>>>> layer has instance element");
        case layerelementtype_tilemap: show_debug_message(">>>>> layer has tilemap element");
        }
    }
}
This won't lock up the computer in an infinite loop and will accurately show the names of the layers in your room as well the elements that are on each layer, which should help you debug the issue.
 
e
Okay.... well, in my experience layers don't generally "just disappear" and if that was the case then many more people would be posting with the issue... which means I have to ask:

Do you have anything in your game that could be removing the layers?
Have you tried cleaning the compiler cache before running (a stale cache can often cause weird errors like this)?
Is it only tile layers that are affected by this?

Also, as a check, a better code would be something like this:

Code:
var _layer = layer_get_all();
for (var i = 0; i < array_length_1d(_layer); ++i;)
{
show_debug_message("Layer " + layer_get_name(_layer[i]) + " exists!!!!");
var _element = layer_get_all_elements(_layer[i])
for (j = 0; j < array_length_1d(_element); ++j;)
    {
    switch (layer_get_element_type(_element[j]))
        {
        case layerelementtype_sprite: show_debug_message(">>>>> layer has sprite element");
        case layerelementtype_background: show_debug_message(">>>>> layer has background element");
        case layerelementtype_instance: show_debug_message(">>>>> layer has instance element");
        case layerelementtype_tilemap: show_debug_message(">>>>> layer has tilemap element");
        }
    }
}
This won't lock up the computer in an infinite loop and will accurately show the names of the layers in your room as well the elements that are on each layer, which should help you debug the issue.
excellent!!! i was thinking about to do this but i didn't know nothing about layerelementtype_ , so i think this can help me a lot!! i will run this code right now and responde you back ASAP! TY
 
Code:
//---------------------------------------------------------------------------------------------
======STACKING TIME FOR LAYERS===========8:23:46 Game 1st attemp, everything is fine
//---------------------------------------------------------------------------------------------
Layer PlatformTiles exists!!!! //<--tiles for Platforms
>>>>> layer has tilemap element
Layer Instances exists!!!!
>>>>> layer has instance element
>>>>> layer has tilemap element
Layer SolidTiles exists!!!! //<--tiles for Solid
>>>>> layer has tilemap element
Layer Players exists!!!!
(written a lot of times)
>>>>> layer has instance element
>>>>> layer has tilemap element
Layer ScreenInter exists!!!!
Layer camera_mover exists!!!!
>>>>> layer has instance element
>>>>> layer has tilemap element
>>>>> layer has instance element
>>>>> layer has tilemap element
Layer CameraZones exists!!!!
(written a lot of times)
>>>>> layer has instance element
>>>>> layer has tilemap element
Layer RoomEnemies exists!!!!
(written a lot of times)
>>>>> layer has instance element
>>>>> layer has tilemap element
Layer RingsYCosas exists!!!!
(written a lot of times)
>>>>> layer has instance element
>>>>> layer has tilemap element
Layer RoomThings exists!!!!
(written a lot of times)
>>>>> layer has instance element
>>>>> layer has tilemap element
Layer BombillasYAdornos exists!!!!
>>>>> layer has tilemap element
Layer WorldDesign exists!!!!
>>>>> layer has tilemap element
Layer WallsBackground exists!!!!
>>>>> layer has tilemap element
Layer ObjetosEntreMundoYFondo exists!!!!
(written a lot of times)
>>>>> layer has instance element
>>>>> layer has tilemap element
Layer Background exists!!!!
>>>>> layer has background element
>>>>> layer has instance element
>>>>> layer has tilemap element
Layer CloudsBg exists!!!!
>>>>> layer has background element
>>>>> layer has instance element
>>>>> layer has tilemap element
//---------------------------------------------------------------------------------------------
======STACKING TIME FOR LAYERS===========8:23:55 Game 2nd attemp, everything is fine
//---------------------------------------------------------------------------------------------
Layer PlatformTiles exists!!!!
>>>>> layer has tilemap element
Layer SolidTiles exists!!!!
>>>>> layer has tilemap element
Layer Players exists!!!!
(written a lot of times)
>>>>> layer has instance element
>>>>> layer has tilemap element
Layer ScreenInter exists!!!!
Layer camera_mover exists!!!!
>>>>> layer has instance element
>>>>> layer has tilemap element
Layer CameraZones exists!!!!
(written a lot of times)
>>>>> layer has instance element
>>>>> layer has tilemap element
Layer RoomEnemies exists!!!!
(written a lot of times)
>>>>> layer has instance element
>>>>> layer has tilemap element
Layer RingsYCosas exists!!!!
(written a lot of times)
>>>>> layer has instance element
>>>>> layer has tilemap element
Layer RoomThings exists!!!!
(written a lot of times)
>>>>> layer has instance element
>>>>> layer has tilemap element
Layer BombillasYAdornos exists!!!!
>>>>> layer has tilemap element
Layer WorldDesign exists!!!!
>>>>> layer has tilemap element
Layer WallsBackground exists!!!!
>>>>> layer has tilemap element
Layer ObjetosEntreMundoYFondo exists!!!!
(written a lot of times)
>>>>> layer has instance element
>>>>> layer has tilemap element
Layer Background exists!!!!
>>>>> layer has background element
>>>>> layer has instance element
>>>>> layer has tilemap element
Layer CloudsBg exists!!!!
>>>>> layer has background element
>>>>> layer has instance element
>>>>> layer has tilemap element
//---------------------------------------------------------------------------------------------
======STACKING TIME FOR LAYERS===========8:24:25 But... a lot of layers don't exists anymore :S
//---------------------------------------------------------------------------------------------
Layer camera_mover exists!!!!
>>>>> layer has instance element
>>>>> layer has tilemap element
Layer Background exists!!!!
>>>>> layer has background element
>>>>> layer has instance element
>>>>> layer has tilemap element
(written a loooooooooooooooooooooooot of times)
tilemap_get_at_pixel() - couldn't find specified tilemap (more than 50 lines of this)
layer_get_depth() - layer not found in current room (11 lines of this)
this is my report using the code you gave me!!

SO! As i explaind before, layers are disappearing! believe it or not!

See, i got this bug before use deleting layers functions, the ===== STACKING line is written three times and every single time my camera follower object runs end_room event
where i wrote layer deleting scripts, why?? because i got this bug before and i thought my Solid and PlatformTiles were not released at all, and i wrote the code to try when i used room_goto these layers could been loaded again!! But this bugs is persistent, and as you can se, the same code in camera follower runs once and once again and if this script was the problem, the problem should be come in first attemp running! but it doesn't! which means that is not a script problem, is a GM memory or cache problem
 
Hello back, what is this function for??? layer_set_target_room(room); ???? xD i think this function was messing my game up because i don't know what is for clearly! So, i decide to comment those lines and test, and everything is running fine! i will give a try to my whole game and i will tell you how it came!
 
Top