How do I create levers that specify specific doors?

Get help using Construct 2

Post » Thu Nov 24, 2016 2:05 am

What I mean is that I want Lever A to open door A, and Lever B to open door B, also I can't seem to make the player able to change the levers frame when they press a button and are overlapping with it.
B
10
S
1
Posts: 12
Reputation: 474

Post » Thu Nov 24, 2016 6:18 am

Make and use an instance variable so when you flip the lever the variable toggles on and off, then use that to decide if the door is open or not.

If Lever A is flipped -> Toggle Lever A Instance Variable 0/1
If Lever A Instance Variable = 0 -> Close Door A
Else -> Open Door A

Repeat the steps for Lever B etc...
B
61
S
20
G
56
Posts: 1,077
Reputation: 35,986

Post » Thu Nov 24, 2016 8:21 pm

Burvey wrote:Make and use an instance variable so when you flip the lever the variable toggles on and off, then use that to decide if the door is open or not.

If Lever A is flipped -> Toggle Lever A Instance Variable 0/1
If Lever A Instance Variable = 0 -> Close Door A
Else -> Open Door A

Repeat the steps for Lever B etc...


But would I have to create a new object for every lever?
B
10
S
1
Posts: 12
Reputation: 474

Post » Fri Nov 25, 2016 9:35 am

J ust give the lever and door a: instance var and you dont have to clone the objects. I will post a capx when i get home.
B
36
S
10
G
9
Posts: 212
Reputation: 6,945

Post » Fri Nov 25, 2016 10:09 am

I had a tutorial on coding doors and locks logic that could help with your current issue and display several techniques you may use.
The use of instance variables is pretty much the way to go. The use of instances instead of new object types as well.
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
289
S
112
G
94
Posts: 7,333
Reputation: 69,293

Post » Fri Nov 25, 2016 11:15 am

For each lever save the UIDs of the doors you want to manipulate, so when u interact, u can access the specific doors u want to use.
B
6
S
2
Posts: 61
Reputation: 1,099

Post » Fri Nov 25, 2016 4:12 pm

@Winged LionMan

Examine this, is kind of the same thing you need. Check the "Moving Platforms" group, there is the "Moving Platform 1" and down the page is "Moving Platform Control on Start of Layout". This is how I've done this.

Link:
https://www.dropbox.com/s/a6qv3uzabgf2t ... .capx?dl=0
B
36
S
10
G
9
Posts: 212
Reputation: 6,945


Return to How do I....?

Who is online

Users browsing this forum: DiabloOvermind, Mayfly, tarek2 and 14 guests