• 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!

GameMaker Help with Persistent room

P

Ponzalskov

Guest
So i'm having a HUGE little problem.
Seems that when I check my room as persistent it "COPIES" some instances of the previous room into the new one.

For example:
I put some solid blocks in persistent room0.
I warp into persisent room1 and that solid blocks seems to have been copied in the exact position of where they where in room0.

Even if room1 is not persistent, it stills have these solid blocks "copied" from previous room0. Strange thing is that this happens only with some instances, like texts and solid blocks, but not with enemies.

I say "copied" in quotes because it doesn't even draw the object in new room.

The only persistent objects that warps are a Controller obj and a Player obj that has no code related to solid blocks.

ANY SUGGESTION ?
 

Relic

Member
I'm not sure if you were trying to imply this already in your post ("warps" comes across as ambiguous), but are any of the solid blocks persistent? Do you set them as persistent in the object editor, or set persistent=true in code?
 
P

Ponzalskov

Guest
I'm not sure if you were trying to imply this already in your post ("warps" comes across as ambiguous), but are any of the solid blocks persistent? Do you set them as persistent in the object editor, or set persistent=true in code?
The only things set Persistent are the Player object (checked in object properties) and both room0 and room1 in the Room Settings tab.

I remade a demostration to show it:

I have a oPlayer object set as persistent

STEP EVENT for oPlayer

Code:
//Inputs
key_right = keyboard_check(vk_right);
key_up = keyboard_check(vk_up);
key_left = keyboard_check(vk_left);
key_down = keyboard_check(vk_down);

//Move
var spd = 2;
var hsp = (key_right - key_left) * spd;
var vsp = (key_down - key_up) * spd;

//Horizontal collision
if place_meeting(x+hsp, y, oSolid) {
    while !place_meeting(x+sign(hsp), y, oSolid) {
        x+=sign(hsp);
    }
    hsp = 0;
}
x+=hsp;

//Vertical collision
if place_meeting(x, y+vsp, oSolid) {
    while !place_meeting(x, y+sign(vsp), oSolid) {
        y+=sign(vsp);
    }
    vsp = 0;
}
y+=vsp;
oWarp as the one that makes the player go to another room

COLLISION WITH OPLAYER EVENT for oWarp
Code:
room_goto(room1);
other.x = 320;
other.y = 240;
In room0, at 320, 240 there is a oSolid object. However, in room1 there is any oSolid object. Yet, when I transfer my oPlayer object to that position at ROOM1, it freezes as if it where colliding with a solid! (I checked this using a Draw Gui event)

 

Relic

Member
To help narrow the problem further, can you confirm that this only happens if you warp the player to a position where oSolid existed in room0? If you move the player to a position that does not have any oSolid instances in either room, is it fine?
 
P

Ponzalskov

Guest
To help narrow the problem further, can you confirm that this only happens if you warp the player to a position where oSolid existed in room0? If you move the player to a position that does not have any oSolid instances in either room, is it fine?
Here is a exact picture of what is happening:

https://imgur.com/a/Q2NXpnp

Room0 is copiying almost every instance into room1 when I enter on it, and viceversa.
The thing is that It happens no matter where I warp the player, and the "copied" instances doesn't draw OR EVEN EXISTS (I used instance_count to know if they really moved into another room) in the new room.
 

Relic

Member
I still don’t have any ideas and need more information. You say the oSolid have moved from room0, indicated by collisions and what you do in GUI draw, yet they don’t exist when checking instance count.

Can you show the code in the GUI draw that allows you to show where these blocks are?
 
P

Ponzalskov

Guest
DRAW GUI event for oPlayer:

Code:
if place_meeting(x, y, oSolid) {
    draw_set_color(c_red);   
} else {
    draw_set_color(c_white);   
}

draw_text(16, 16, "is_colliding? ");
draw_text(16, 32, "total_instances "+string(instance_count));
 

Relic

Member
Oh, so the draw GUI doesn’t show where these blocks are, only that a collision has occurred.

Does your game freeze it like it’s stuck in a loop? Can you add a counter to your draw GUI to see if it keeps looping?
 
P

Ponzalskov

Guest
Oh, so the draw GUI doesn’t show where these blocks are, only that a collision has occurred.

Does your game freeze it like it’s stuck in a loop? Can you add a counter to your draw GUI to see if it keeps looping?
The game doesn't freezes like a loop, you can just keep trying to move but with no response, like the player was stuck inside the block.
If I teleport the player to another position, the room still has this "transparent unexisten blocks" remains from the previous Persistent room.

Anyway, thank you for your Help, but I translated the whole project into Physics and it works even better than before.
Thank you so much for your help and your time !
 
Top