tilemap_get_at_pixel couldn't find specific tilemap

I started adding a title screen so I can get out a demo of some sort. basically all it does is display an image then switch to the actual game room when the player presses space.

However, doing so seems to completely break the tilemap for one of my objects. When I load the room normally, as in it's the first room that loads when you start the game, it's fine, but if I load the room from this title screen via room_goto(); it throws this error tilemap_get_at_pixel couldn't find specific tilemap and collisions no longer work.

Here's the code for the object:

create event:
Code:
image_alpha = 0;

target = obj_ow_player_tank;

depth = -1;

//this determines what cell the player is in
squareX = 0;
squareY = 0;

//used for tile updates
xStore = target.x;
yStore = target.y;
update = true;

//for the square detection space you can take the length, subtract 1, then divide by two to get the start point.
//note: the below are measured in cells of 32 pixels
endCellGen = 33; //basically the length of each of the update box' sides, centered on the player
startCellGen = (endCellGen - 1) /2;

endCellClean = endCellGen + 2; //basically the length of each of the delete box' sides, centered on the player
startCellClean = (endCellClean - 1) /2;
ImobCellClean = startCellClean * 32;

//note: the below is needed to allow other objects to access the Tiles_1 layer for detection
var l = layer_get_id("Tiles_1");
global.Tiles_1 = layer_tilemap_get_id(l);

arrayMax = 5; //used to prevent out of bounds errors
//global.blockArray = ds_list_create();
global.blockArray[0] = 0;
global.blockArray[1] = obj_ow_generic;
global.blockArray[2] = obj_ow_nopass_block;
global.blockArray[3] = obj_ow_rock;
global.blockArray[4] = obj_ow_ore_vein;
global.blockArray[5] = obj_ow_nopass_hidden;
step event:
Code:
squareX = round(target.x / 32) * 32;
squareY = round(target.y / 32) * 32;

//tilecheck x/y for loop
//within loop:
//check for block
//if block, do nothing
//else
//if tile index > 0 (later we'll add in the ability to check for tileSet type which will load a unique array
//produce block from array (1 = block1, 2 = block2, etc
//else
//do nothing

if(target.x > xStore + 31 || target.x < xStore - 31)
{
    update = true;
    xStore = target.x;
}
if(target.y > yStore + 31 || target.y < yStore - 31)
{
    update = true;
    yStore = target.y;
}

if(update = true)
{
    for(var xx = 0; xx < endCellGen; xx ++)
    {
        for(var yy = 0; yy < endCellGen; yy ++)
        {
        
            var posX = squareX - (32 * (startCellGen - xx));//change these values to lengthen the box. later on, add a var to change these more easily
            var posY = squareY - (32 * (startCellGen - yy));

            if(instance_position(posX, posY, obj_ow_nopass) = noone)
            {
                var temp1 = tilemap_get_at_pixel(tileset0,posX, posY);
                var temp2 = tile_get_index(temp1);
                if(temp2 > 0)
                {
                    if(temp2 <= arrayMax)
                    {
                    var tempTarg = instance_create_depth(posX, posY, -1, global.blockArray[temp2]);
                    var3 = tempTarg;
                    }

                }
            }
        }
    }


//cleanup
//have slightly larger square to check for blocks
//Or run 4 for loops that target the 4 sides of the large generation collider above
//if block within this area but not in the above area
//if block does NOT have delete immunity
//kill block

    for(var xx = 0; xx < endCellClean; xx ++) //this deletes top blocks
    {
        var posX = squareX - (32 * (startCellClean - xx));
        var posY = squareY - ImobCellClean;

        if(instance_position(posX, posY, obj_ow_nopass) != noone )
        {
            var tempTarg = instance_position(posX,posY,obj_ow_nopass);
            instance_destroy(tempTarg.upObj);
            instance_destroy(tempTarg.downObj);
            instance_destroy(tempTarg.myShadow);
            instance_destroy(tempTarg);
        }
    }

    for(var xx = 0; xx < endCellClean; xx ++) //this deletes top blocks
    {
        var posX = squareX - (32 * (startCellClean - xx));
        var posY = squareY + ImobCellClean;

        if(instance_position(posX, posY, obj_ow_nopass) != noone )
        {
            var tempTarg = instance_position(posX,posY,obj_ow_nopass);
            instance_destroy(tempTarg.upObj);
            instance_destroy(tempTarg.downObj);
            instance_destroy(tempTarg.myShadow);
            instance_destroy(tempTarg);
        }
    }

    for(var xx = 0; xx < endCellClean; xx ++) //this deletes top blocks
    {
        var posX = squareX - ImobCellClean;
        var posY = squareY - (32 * (startCellClean - xx));

        if(instance_position(posX, posY, obj_ow_nopass) != noone )
        {
            var tempTarg = instance_position(posX,posY,obj_ow_nopass);
            instance_destroy(tempTarg.upObj);
            instance_destroy(tempTarg.downObj);
            instance_destroy(tempTarg.myShadow);
            instance_destroy(tempTarg);
        }
    }

    for(var xx = 0; xx < endCellClean; xx ++) //this deletes top blocks
    {
        var posX = squareX + ImobCellClean;
        var posY = squareY - (32 * (startCellClean - xx));

        if(instance_position(posX, posY, obj_ow_nopass) != noone )
        {
            var tempTarg = instance_position(posX,posY,obj_ow_nopass);
            instance_destroy(tempTarg.upObj);
            instance_destroy(tempTarg.downObj);
            instance_destroy(tempTarg.myShadow);
            instance_destroy(tempTarg);
        }
    }

    update = false;
}
tips on making my code less garbage are also welcome
 

Slyddar

Member
tilemap_get_at_pixel couldn't find specific tilemap
The tilemap is not defined for that room, as the layers may of changed between rooms. Have an object that is persistent run your tilemap code in the room_start event. Might also be able to run it in the room creation code too, but you would then need to do it to every further room. Also ensure the Tiles_1 layer exists in that room.
Code:
//note: the below is needed to allow other objects to access the Tiles_1 layer for detection
var l = layer_get_id("Tiles_1");
global.Tiles_1 = layer_tilemap_get_id(l);
 
Top