Pressure Plate Logic OR Gate situation

Get help using Construct 2

Post » Thu Dec 31, 2015 1:44 am

So I'm trying to create an OR gate situation with pressure plates. My current system worked until I started replacing the placeholder graphics with animations. My current system works like this:

Each Pressure Plate has an instance variable that defines a target door by UID. When that pressure plate is weighed down it will pick the door by UID and call a function that "opens" the door by disabling the collision and changes the animation. That means it also needs an opposite event that processes for pressure plates that are no longer weighed down like so:

For Each [Pressure Plate] (and) [Pressure Plate] is NOT overlapping [Weight] = Close [Door], change animation
For Each [Pressure Plate] (and) [Pressure Plate] is overlapping [Weight] = Open [Door], change animation

The order of these events meant that open doors were processed last and everything worked well, then I added animations and realized that I had one huge problem. The nature of game means that I often have two pressure plates triggering one door, it is kind of a cornerstone of the puzzle design. Because of the way these events are processed my animations are triggered every single tick any any situation where I have two pressure plates that aren't on the same state. Even if I use a Trigger Once event it doesn't mean anything because the door is technically being disabled and then enabled in the next line in the same tick.

So that is where I'm at. This isn't a true OR gate since the signal is really just flickering, and I've been trying to find ways to abstract the events in whatever way to break this on-off flicker. I'm just having a really hard time figuring out a method, I'm sure there must be an easy way about this too.
B
12
S
1
Posts: 6
Reputation: 559

Post » Thu Dec 31, 2015 1:52 am

I don't see why you use for each here?
Wouldn't this work?

weight is overlapping pressure plate
--pick door where door.uid is pressureplate.variable
door open
-- else
door close
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 » Thu Dec 31, 2015 2:10 am

I've tried that, but it only functions properly if I have a single target in a layout. If I add a second pair of a pressure plate + door then only the first one will trigger and any additional sets will stick in the default state.
B
12
S
1
Posts: 6
Reputation: 559

Post » Thu Dec 31, 2015 2:49 am

Ok..
Cant make an example capx right now, but it should work something like that..
For each isn't nescessary and in this case might work against you..

weight is overlapping pressureplate
pick door by comparison door.uid = pressureplate.variable
- door open

weight is not overlapping pressureplate
pick door by comparison door.uid = pressureplate.variable
- door close

this way only the referenced instances will respond..
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 » Thu Dec 31, 2015 4:09 am

That sounds similar to what I'm already doing.

The issue arises when I have two pressure plates pointing at the same door. So for example player1 has to stand on a pressure plate to open the gate and let player2 through, but player2 can't follow through the gate until player1 locates another pressure plate to hold the door open so both can proceed. In these cases you have one door being referenced by two plates, one sending an Off signal, the other sending an On signal. If both pressure plates are off, the door animates correctly, if both pressure plates are on, the door animates correctly, but if there is any mix of on and off then the animation sticks.

I've uploaded a stripped-down example of what I'm working with here: http://www.silvite.com/crap/PressurePlates.capx

And thank you for your replies, I do appreciate the help.
B
12
S
1
Posts: 6
Reputation: 559

Post » Sun Jan 03, 2016 10:53 pm

So for anyone interested I found a workaround for this issue.

On top of having a target UID for each trigger, I also added a variable for Channel. I used a default value of 1, but could go as high as the target had inputs.

In each target item I then added three variables for In1, In2, and In3. This allowed me to have up to three items triggering the same target, but it could be only two depending on your needs.

I then modified my events so that each trigger is sending a 1 or a 0 to UID.Channel#. Each target then had an event that summed all of the 1s and 0s being sent to it and would be off if the sum was 0, or be on if the sum was greater than 0.

This did the trick and allowed me to have multiple triggers sending off or on triggers to the same target without that target wigging out.
B
12
S
1
Posts: 6
Reputation: 559

Post » Mon Jan 04, 2016 3:58 pm

@LumensAquilae If you're still working on this I did something similar with weighted buttons where button-triggered objects could have multiple inputs & also require a minimum number of inputs before activating:

https://dl.dropboxusercontent.com/u/523 ... ample.capx

It uses families so it's easy to add new triggered objects - just add them to the family & make a new event in the triggeredLinkedUID function.
B
27
S
12
G
1
Posts: 157
Reputation: 3,359


Return to How do I....?

Who is online

Users browsing this forum: tarek2, VarunGulyani and 1 guest