Legacy GM issue with activation/deactivation

EZTALES

Member
hey yall,
I need some help with a small issue I'm having with turning off/on activation. basically I have my player touch a door object, which the code for is down below.
Code:
Collision Event with obj_player (this is drag and )
set variable obj_player_stats.playeract to false
Go to room rm_workplace_cutscene
code for playeract is down below. playeract is basically a toggle to see if instance_activate is on or off for the player.
Code:
///player activation
if (playeract != true) {
instance_deactivate_object(obj_player);
}
else
{
instance_activate_object(obj_player);
}
and finally the step event for my cutscene room.
Code:
STEP EVENT FOR CUTSCENE
if (currentMsg == ds_list_size(msg)) //if we're out of messages
    {
        ison=false
        ds_list_destroy(msg); //release the memory
        instance_destroy(); //destroy the message object
    obj_player_stats.playeract = true
    room_goto(rm_workplace_1)   
    instance_destroy(obj_wall_2)
    }
basically, when the room ends i want to go back to the previous room (---->rm_workplace_1 is the previous room <----) and reactivate the player. everything works up until the part where the player is reactivated because when the cutscene is over the player is completely gone from the room and I can't for the life of me figure out why. if anyone has any idea hmu. thanks!
 
I'm not totally sure I follow...

Your running the ///player activation code every step right?

I think the problem though is that you are deactivating the player so it's no longer accessible, then you are trying to set a variable in inside (while it's deactive) and expecting it to reactivate when that variable is set, but it doesn't work that way. Once an object is deactive it can't reactivate itself, you have to activate externally. So when your leaving the room don't set the variable, just activate the object instead.
 

EZTALES

Member
I'm not totally sure I follow...

Your running the ///player activation code every step right?

I think the problem though is that you are deactivating the player so it's no longer accessible, then you are trying to set a variable in inside (while it's deactive) and expecting it to reactivate when that variable is set, but it doesn't work that way. Once an object is deactive it can't reactivate itself, you have to activate externally. So when your leaving the room don't set the variable, just activate the object instead.
oh, I kinda understand what your getting at but ill just let you know now that obj_player_stats is not the player. I'll try to make a separate object to change it.
 
Ah ok, I see. Your player object is it persistent? Do you have the ///player activation code running on the second room? If so, it is probably deactivating the player since the variable gets reset on the next room.
 

Yal

GMC Memer
GMC Elder
hey yall,
You misspelled my name :v

First of all, instance activation / deactivation only happens at the end of a step so you need to wait one step after issuing an activation command to be able to access objects with a with loop, or ensure persistent objects exists before a room change instead of still being in hammerspace.

Secondly, you change rooms instantly after setting the variable so the step event that activates / deactivates things won't have a chance to run anyway.
Code:
obj_player_stats.playeract = true
room_goto(rm_workplace_1)
(So set an alarm to 3 steps that will change rooms and you should be fine)
 

EZTALES

Member
Ah ok, I see. Your player object is it persistent? Do you have the ///player activation code running on the second room? If so, it is probably deactivating the player since the variable gets reset on the next room.
Ohhhh that's a possibility thank you
 
Top