Cant choose different character after i go back to menu

Discussion in 'Programming' started by Mark Francis, Mar 17, 2019.

  1. Mark Francis

    Mark Francis Member

    Joined:
    Mar 17, 2019
    Posts:
    3
    so im developing a fighting game and the only problem is i cant choose again a different character after the fight ends. Example i choose A for player1 and B for A.I and when the game ends theres a button in my room which will go back to my character_select room and when i choose again different character example i chose C for player1 and D for AI , A will go back to my fighting room and D working fine. i hope u all got my point sorry for my bad english . I HOPE U GUYS CAN HELP ME

    PS. i use global variables. global.player = noone; global.enemy = noone;
     
  2. VagrantWhaleGames

    VagrantWhaleGames Member

    Joined:
    Jul 10, 2018
    Posts:
    58
    Global variables are persistent so make sure you aren't setting/resetting them unintentionally...Hard to say where the exact error is without seeing some code. For example, make sure you set those global variables up in the beginning of the game, not every time you go back to the character_select room.
     
  3. Mark Francis

    Mark Francis Member

    Joined:
    Mar 17, 2019
    Posts:
    3
    i have this object that control global.player and global.enemy
    in global.player create event heres my only code : instance_change(global.player,true);
    in global.enemy also in creave event : instance_change(global.enemy,true);
     
  4. VagrantWhaleGames

    VagrantWhaleGames Member

    Joined:
    Jul 10, 2018
    Posts:
    58
    global.player should be a variable not an object. Ex. global.player = objPlayer0; global.enemy=objEnemy0;

    ///create event of control object
    global.player=objPlayer0;

    //create event of player
    if(global.player != -1)
    {
    instance_change(global.player,true);
    }

    other then that, I think you still may be resetting the variable somewhere. In the future maybe using an array to store characters and their values and applying them to the player might be a good idea, i'm not the biggest fan of using instance change.
     
    Last edited: Mar 17, 2019

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice