Legacy GM Respawn exactly inside the room without restarting it.

S

Sugor

Guest
Can anyone help on making a respawn at the exact room without restarting the room and with death animation...
I used the if (hp <= 0) {
Instance_destroy();
}

Instead of making it destroy anyone has an idea?
 
T

trentallain

Guest
Can anyone help on making a respawn at the exact room without restarting the room and with death animation...
I used the if (hp <= 0) {
Instance_destroy();
}

Instead of making it destroy anyone has an idea?
Create a controller object that checks a global variable for hp and keeps track of the object's x and y that you want to respawn. If the hp is <= 0 then destroy the object and then recreate it at the x and y you stored. To have a death animation, just have a variable that is false until the object is dead, then play the animation and then destroy it.
 
S

Sugor

Guest
Create a controller object that checks a global variable for hp and keeps track of the object's x and y that you want to respawn. If the hp is <= 0 then destroy the object and then recreate it at the x and y you stored. To have a death animation, just have a variable that is false until the object is dead, then play the animation and then destroy it.
Thank you I already think of that just to make sure...I haven't tested yet I'm fixing my laptop
 

JasonTomLee

Member
Here's some example code you could try out~
Lmk if you got any questions- happy to help

Code:
[ Spawn Player right away ]

//Destroy event of Player Object
instance_create( x,y, oPlayer );

[ or create the Player after a set respawn time ]

// Destroy Event of Player Object
with( oController ){
spawnx = other.x;
spawny = other.y;
alarm[ 0 ] = room_speed;//spawn timer
}

//oController Object//
//Create
spawnx = 0;
spawny = 0;

//Alarm[0]
instance_create( spawnx, spawny, oPlayer );
 
S

Sugor

Guest
Here's some example code you could try out~
Lmk if you got any questions- happy to help

Code:
[ Spawn Player right away ]

//Destroy event of Player Object
instance_create( x,y, oPlayer );

[ or create the Player after a set respawn time ]

// Destroy Event of Player Object
with( oController ){
spawnx = other.x;
spawny = other.y;
alarm[ 0 ] = room_speed;//spawn timer
}

//oController Object//
//Create
spawnx = 0;
spawny = 0;

//Alarm[0]
instance_create( spawnx, spawny, oPlayer );
am i suppose to put it on step event Then put inside of the if (Hp <= 0) { } or
Or i will put Destroy event then put the script?
Code:
[ Spawn Player right away ]

//Destroy event of Player Object
instance_create( x,y, oPlayer );

[ or create the Player after a set respawn time ]

// Destroy Event of Player Object
with( oController ){
spawnx = other.x;
spawny = other.y;
alarm[ 0 ] = room_speed;//spawn timer
}
 

JasonTomLee

Member
@Sugor
You could do either!
But I prefer putting death code inside the Destroy Event because it keeps things organized & it triggers the code only once.

So you'd keep your current code of:
if ( Hp <= 0 ) { instance_destroy }

Then the instance_destroy would trigger the Destroy event because the object no longer exists. Make sure to create the Controller object as well! Lmk if you still need help w/that mate
 

Yal

šŸ§ *penguin noises*
GMC Elder
The easiest way to do this is to make the player object create a new player object at its xstart/ystart position when it's destroyed. When you touch a checkpoint, create a new player object at it and destroy the old one. (Or change xstart / ystart - you CAN change them)
 
Top