Pressure Plate Logic OR Gate situation

0 favourites
  • 7 posts
From the Asset Store
100 items casual and logic games. All icons are of a high quality.
  • 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.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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'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.

  • 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..

  • 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:

    And thank you for your replies, I do appreciate the help.

  • 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.

  • 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: ... 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.

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