How do I get this switch to work

Get help using Construct 2

Post » Mon Nov 16, 2015 11:33 pm

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"
B
38
S
12
G
5
Posts: 151
Reputation: 5,338

Post » Mon Nov 16, 2015 11:38 pm

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".
ImageImageImage
B
71
S
22
G
257
Posts: 3,790
Reputation: 142,696

Post » Mon Nov 16, 2015 11:39 pm

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..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Mon Nov 16, 2015 11:43 pm

Ah, that's it, thank you both! I knew it had to be something simple I overlooked, it's working now :) Thanks again!
B
38
S
12
G
5
Posts: 151
Reputation: 5,338


Return to How do I....?

Who is online

Users browsing this forum: Google [Bot], lemonizer, R0J0hound and 1 guest