0 Favourites

How do I: Make Global variable change it's state.

  • Good evening pals. Im having a problem in my character selection.

    I have two playable characters in game and a Global variable "ActiveCharacter" where i have determined 1 as first character and 2 as second one.

    Here's the event sheet and gif from what happens. So basically it works with mouse but with gamepad it doesn't change from 1 to 2. But if i active the character two with mouse it lets me change back to character one with gamepad.

    Event sheet.

    Gif.

    I remember having similiar problem before but couldnt find the .capx or solution anymore.

  • Let me give you an example why this doesn't work.

    Let's go event by event.

    • You start with ActiveCharacter=1 and ActiveScreen=2
    • You press left on the Gamepad
    • Line 6 triggers and sets ActiveCharacter to 2
    • In the same tick, the event in line 9 triggers since ActiveCharacter is now 2 and sets it back to 1

    To you, this looks like nothing happened.

    The mouse events work since there can only be one mouse event happening at the same time.

    What you need to do, is replace ActiveCharacter=2 in line 8 with "Else".

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • Let me give you an example why this doesn't work.

    Let's go event by event.

    • You start with ActiveCharacter=1 and ActiveScreen=2
    • You press left on the Gamepad
    • Line 6 triggers and sets ActiveCharacter to 2
    • In the same tick, the event in line 9 triggers since ActiveCharacter is now 2 and sets it back to 1

    To you, this looks like nothing happened.

    The mouse events work since there can only be one mouse event happening at the same time.

    What you need to do, is replace ActiveCharacter=2 in line 8 with "Else".

    Yup. That did it! Thanks alot mate. I found the one .capx where i had this similar problem and the Else-condition did it.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic
313 26,497
Juryiel's avatar
Juryiel
Unread hot topic Locked topic
195 16,198
Ashley's avatar
Ashley Construct Team Founder
Unread hot topic
167 14,512
DMT2005's avatar
DMT2005