I dont know what im doing wrong

0 favourites
  • 3 posts
From the Asset Store
Be quick and choose whether the shown equation is right or wrong.
  • Here's what im trying to do.

    There are 3 rooms; A, B, and C.

    Room A is the room with the switch.

    The switch, if pressed while Variable=0, sets variable to 1

    If pressed while Variable=1, it sets the variable to 0

    If the variable=0 and you hit the arrow on screen, you go to room B.

    If the variable=1 and you hit the arrow on screen, you go to room C.

    I set it up perfectly and you only go to room B. Help?

  • Hi

    The problem (as far as i understand) is that u set the variable to 1 if the switch is pressed.

    Now in my experience u dont want to "set" the switch to 1.

    Because construct2 recognises u pressing the switch even after it has set that variable.

    The result is this:

    Pressed switch --> set variable to 1 --> set variable to 0

    So when u then hit the arrow on screen, u go to Room B.

    To make switches using variable i always do the following.

    I came up with this method after having the same problem long time ago.

    Here is what i do all the time and it works.

    Press switch --> Add 1 to variable

    Variable = 0 (Do Action)

    Variable = 1 (Do Action)

    Variable is greater or = 2 (set variable to 0)

    This event logic makes the switch cycle through the variable, and by reaching the end it starts at Zero again.

    With this u can make as many variable actions as u need.

    Press switch --> Add 1 to variable

    Variable = 0 (Do Action)

    Variable = 1 (Do Action)

    Variable = 2 (Do Action)

    Variable = 3 (Do Action)

    Variable = 4 (Do Action)

    Variable = 5 (Do Action)

    Variable = 6 (Do Action)

    Variable = 7 (Do Action)

    Variable = 8 (Do Action)

    Variable is greater or = 9 (set variable to 0)

    U can also use these variable "amounts" in other events.

    In your case it would look like this.

    Press switch --> Add 1 to variable

    Press Arrow & Variable = 0 (Room B)

    Press Arrow & Variable = 1 (Room C)

    Variable is greater or = 2 (set variable to 0)

    Ps: My name is not david either <img src="smileys/smiley32.gif" border="0" align="middle" />

    Kind Regards

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • thank you so much!

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