How do I make an on off switch?

  • How can i create an on/off switch that uses the same key to activate it?

    I know there must be a bunch of different ways but I cant get them to work.

    The following works fine when I use two different keys, like numpad 1 and numpad 2.

    But when I set both to one key like numpad 1, nothing happens at all.

    If someone could let me what am missing here I would appreciate any help.

    start of lay out: "switch" set to not mirrored

    1. Key numpad 1 pressed on keyboard = Set "switch" to mirrored

    "Player" overlapping "switch"

    "switch" is mirrored (inverted,

    there is no other mirror option)

    2. Key numpad 1 pressed on keyboard = Set "switch" to not mirrored

    "Player" overlapping "switch"

    "switch" is mirrored (not inverted)

    I tried the same thing with two animations, even tried two separate switches that spawn each other.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hiya, this is a common issue I see people get stuck on. Due to Construct's top to bottom running of events what is actually happening here is it's setting something in event 1, which makes event 2 true and then it runs event 2. So in the same 'tick' which you won't see with the naked eye, it is toggling something on and off again. Some people try to resolve this with waits or timers which can also cause problems, I prefer to pass toggle options through a function, see my screenshot in this post : construct.net/en/forum/construct-3/how-do-i-8/how-do-i-create-a-character-sw-142015

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)