Legacy GM [SOLVED] Strange object's behavior after changing name

S

Silver978

Guest
Hello everyone!

I have different rooms in my game with a creation code (such as for spawning the player, enemies, ...) and I wanted to create a new room by duplicating one of the others to save time.
In the new room's creation code I changed the name of the player's object to a different one but when I test the game and this new object is spawned it is "freezed": it doesn't move and the Step Event is completely ignored.
I checked for infinite loops and I tried to put a "show_message("...")" in the Step Event, but nothing appears.

So, I ask if anyone have an idea about this strange behavior?

Thank you very much in advance,

Silver978
 

jo-thijs

Member
Hi and welcome to the GMC!

We will need more information in order to be able to tell what's going on.

Could you try putting the show_message in the create event?
Could you give the object information of the relevant objects?
Could you give the room creation code?
 
S

Silver978

Guest
Hi and welcome to the GMC!

We will need more information in order to be able to tell what's going on.

Could you try putting the show_message in the create event?
Could you give the object information of the relevant objects?
Could you give the room creation code?
Thank you! :)

Sure! Now I will answer to you:
- 1: I've tried that and it worked, if I put "show_message" in the Create Event it shows up!
- 2: Yes, I will post the object information about the player's object:

Information about object: obj_player_1
Sprite: spr_player
Solid: true
Visible: true
Depth: -2
Persistent: false
Parent:
Children:
Mask:
No Physics Object
Create Event:
execute code:

no_damage = false;
change_on = false;

//PARAMETRI SUL MOVIMENTO
//Velocità di movimento
player_speed = 5;

Alarm Event for alarm 0:
execute code:

no_damage = false;
sprite_index = spr_player;

Alarm Event for alarm 1:
execute code:

if(global.floor2_on == true && global.pause == false)
{
global.life--;
}
change_on = false;
alarm[1] = global.time_damage;


Step Event:
for all obj_player: execute code:

/*Se il gioco è in pausa, allora si distinguono due casi:
1) Se il giocatore ha appena iniziato la partita, la pausa è sfruttata per BLOCCARE TUTTI I ROBOT e lasciare libero di
muoversi il giocatore per i primi due secondi;
2) Se ci troviamo in pausa vera e propria Zimbli può solo muoversi, ma dato che non sono presenti i tasti di movimento nella
schermata di pausa, il giocatore non può comunque muoversi e abbiamo un'effettiva fase di pausa dal gioco.
*/

if (global.pause) exit;

if(instance_number(obj_robot)>0)
{
//INTERFACCIA ANDROID//
//Movimento del giocatore attraverso il primo joystick
hspeed = vstick_get_xaxis(0)*player_speed;
vspeed = vstick_get_yaxis(0)*player_speed;
//Rotazione del giocatore mediante lo stesso joystick
image_angle = vstick_get_direction(0);
direction = vstick_get_direction(0);

//Rotazione attraverso il secondo joystick
//image_angle = vstick_get_direction(1);

/*if(keyboard_check(vk_right))
{
image_angle-=15;
direction-=15;
}

if(keyboard_check(vk_left))
{
image_angle+=15;
direction+=15;
}

if(!keyboard_check(vk_right)&&!keyboard_check(vk_left)&&keyboard_check(vk_up))
{
speed=8;
}
else if(keyboard_check_released(vk_up))
{
speed=0;
}

if(!keyboard_check(vk_right)&&!keyboard_check(vk_left)&&keyboard_check(vk_down))
{
speed=-8;
}
else if(keyboard_check_released(vk_down))
{
speed=0;
}*/

//PASSAGGIO AL SECONDO FLOOR
if(place_meeting(x,y,obj_hole)&&keyboard_check_pressed(vk_space))
{
if(global.floor2_on == false)
{
global.floor2_on = true;
}
else
{
global.floor2_on = false;
}
}
}
else
{
speed = 0;
}

//LIMITI DEL LIVELLO PER IL GIOCATORE
if(x > 1024)
{
x-=5;
}
else if(x<0)
{
x+=5;
}

if(y > 768)
{
y-=5;
}
else if(y < 0)
{
y+=5;
}

//COLLISIONE CON IL ROBOT O CON IL SUO PROIETTILE
if(instance_number(obj_robot)>0)
{
if(obj_robot.visible && no_damage == false)
{
if(place_meeting(x,y,obj_robot))
{
if(no_damage == false)
{
//CONTROLLO DELL'ABILITAZIONE O MENO DEGLI EFFETTI SONORI DI GIOCO
//Si controlla se gli effetti sonori sono stati abilitati o meno nel menù delle opzioni
//controllando l'apposita variabile
//L'effetto sonoro viene riprodotto SOLO se sono stati abilitati nel menù "OPTIONS"
if(global.sound_effects_on == 1)
{
audio_play_sound(snd_hit,9,false);
}

global.life--;
alarm[0]=60;
sprite_index = spr_playerHIT;
no_damage = true;
}
}
}
}

//IL GIOCATORE CAMBIA PIANO ED E' SOTTOPOSTO AI GAS VELENOSI
if(global.floor2_on == true && global.pause == false)
{
if(change_on == false)
{
alarm[1] = global.time_damage;
change_on = true;
}

}

//IL GIOCATORE VUOLE SPARARE
if(keyboard_check_pressed(vk_control) && global.init_pause == false)
{
//CONTROLLO DELL'ABILITAZIONE O MENO DEGLI EFFETTI SONORI DI GIOCO
//Si controlla se gli effetti sonori sono stati abilitati o meno nel menù delle opzioni
//controllando l'apposita variabile
//L'effetto sonoro viene riprodotto SOLO se sono stati abilitati nel menù "OPTIONS"
if(global.sound_effects_on == 1)
{
audio_play_sound(snd_shot,5,false);
}

action_create_object_motion(obj_shot,x,y,10,direction);
}




Collision Event with object obj_shot2:
execute code:

if(no_damage == false)
{
//Il giocatore ha perso vita e quindi NON può ottenere la medaglia BULLETPROOF
global.bulletproof_active = false;

//CONTROLLO DELL'ABILITAZIONE O MENO DEGLI EFFETTI SONORI DI GIOCO
//Si controlla se gli effetti sonori sono stati abilitati o meno nel menù delle opzioni
//controllando l'apposita variabile
//L'effetto sonoro viene riprodotto SOLO se sono stati abilitati nel menù "OPTIONS"
if(global.sound_effects_on == 1)
{
audio_play_sound(snd_hit,9,false);
}

global.life--;
alarm[0]=60;
sprite_index = spr_playerHIT;
no_damage = true;
}

Sorry for the italian comments, if you have any question about them tell me!

- 3: Yes, sure, here it is:

//PLAYER CREATION
uscita = false;

while(uscita==false)
{
num_player_x = irandom_range(0,global.gameX-1);
num_player_y = irandom_range(0,global.gameY-1);

if(global.level_matrix[num_player_x,num_player_y] == 0)
{
//Player 1 placement
instance_create((num_player_x*dim_panel)+32,(num_player_y*dim_panel)+32,obj_player_1);

uscita=true;
}
}

I posted the part about the player's object which, maybe, is causing the problem.
The creation code of the room generates a matrix of panels which will define the "ground" of the level and then the enemies and the player are placed in random positions.

Thank you again for your fast response,

Silver978
 

jo-thijs

Member
Is there an active instance of type obj_player in the room?
And are you aware that you've checked the box of the code in the step event of obj_player_1
to execute for all instances of type obj_player, rather than execute it by the current instance?
 
S

Silver978

Guest
Is there an active instance of type obj_player in the room?
And are you aware that you've checked the box of the code in the step event of obj_player_1
to execute for all instances of type obj_player, rather than execute it by the current instance?
No, there aren't active instances of type obj_player in the room and I named the new object "obj_player_1" only to avoid confusion.
Sorry for my question, but I never noticed that "execute for all obj_player" in the Step Event and I want to execute it only for the current instance, maybe is connected to the fact that I duplicated the object "obj_player" in order to make a new one "obj_player_1"?

Silver978
 
S

Silver978

Guest
No, duplicating it doesn't change that option.

Anyway, is the issue solved when you change the option?
YES! Thanks to you it worked and I also understood this aspect.
Now I can continue my project :)

Thank you very much again for your help jo-thijs!! :D

Silver978
 
Top