1. Hey! Guest! The 36th GMC Jam will take place between February 27th, 12:00 UTC - March 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice

GM:S 1.4 issue with activation/deactivation

Discussion in 'Programming' started by EZTALES, Feb 12, 2020 at 6:19 PM.

Tags:
  1. EZTALES

    EZTALES Member

    Joined:
    Apr 15, 2018
    Posts:
    182
    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!
     
  2. robproctor83

    robproctor83 Member

    Joined:
    Sep 30, 2019
    Posts:
    292
    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.
     
  3. EZTALES

    EZTALES Member

    Joined:
    Apr 15, 2018
    Posts:
    182
    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.
     
  4. robproctor83

    robproctor83 Member

    Joined:
    Sep 30, 2019
    Posts:
    292
    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.
     
  5. Yal

    Yal GMC Memer GMC Elder

    Joined:
    Jun 20, 2016
    Posts:
    4,214
    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)
     
  6. EZTALES

    EZTALES Member

    Joined:
    Apr 15, 2018
    Posts:
    182
    Ohhhh that's a possibility thank you
     

Share This Page