How do I get this switch to work

  • Ok, too tired to think clearly, can't figure out what I have to do here to get this simple switch working. I identify the switches by instance variables and the switch activates Ok, but the state doesn't change, it just moves the block in one direction and one direction only. Can anyone spot what I'm doing wrong/missing here? Code below:

    PLAYER Is overlapping SWITCH

    --> System Pick BLOCK where BLOCK.ID = SWITCH.ID

    ----> Keyboard on Z pressed

    ------> BLOCK variable "state" = "deactive" -> BLOCK MoveTo move to (self.X, self.Y + 64) | Set state to "active"

    ------> BLOCK variable "state" = "active" -> BLOCK MoveTo move to (self.X, self.Y - 64) | Set state to "deactive"

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Use an ELSE between your two state tests, otherwise you are setting the state to "active" then the very next line checks if it is "active", which it is, because you just set it to "active", and then sets it back to "deactive".

  • Construct2 reads events topmto bottom..

    After this event has done it's action

    -> BLOCK variable "state" = "deactive" -> BLOCK MoveTo move to (self.X, self.Y + 64) | Set state to "active"

    this event is automatically true and its actions will execute

    -> BLOCK variable "state" = "active" -> BLOCK MoveTo move to (self.X, self.Y - 64) | Set state to "deactive"

    In this case using an "else" event would solve this..

  • Ah, that's it, thank you both! I knew it had to be something simple I overlooked, it's working now Thanks again!

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