Door not working when all keys collected

I have 5 keys hidden in this level. When all 5 are collected AND the player collides with the door, you are supposed to go to the next level. It is not working as intended and I can’t figure out why. The game is bellow.

Ok go to your door and edit the behaviors delete all thats there and paste this into it

{“data”:{“behavior”:{“v”:“2”,“nodes”:[{“inputCount”:0,“outputCount”:1,“name”:“Collision”,“behaviorType”:“logic.triggers.Collision”,“x”:180,“y”:-32,“group”:"",“id”:“e9405f9b1d22424f”,“targetClassId”:8923391,“targetEntityId”:0,“collisionFilter”:15,“collideWithEntity”:false,“delay”:0},{“gateVal”:0,“mode”:“equal to”,“inputCount”:2,“outputCount”:2,“name”:“Filter”,“behaviorType”:“logic.logic.Filter”,“x”:180,“y”:-160,“group”:"",“id”:“e940add378d29340”},{“inputCount”:3,“outputCount”:1,“name”:“Global”,“behaviorType”:“logic.logic.Global”,“x”:360,“y”:-32,“group”:"",“id”:“e9415a17e3a03044”,“tag”:“Keys Remaining”},{“inputCount”:3,“outputCount”:1,“name”:“Number”,“behaviorType”:“logic.logic.Value”,“x”:360,“y”:96,“group”:"",“id”:“e9416a4e1f074f47”,“startVal”:5,“tag”:""},{“inputCount”:2,“outputCount”:2,“name”:“NextLevel”,“behaviorType”:“logic.gameflow.NextLevel”,“x”:540,“y”:-160,“group”:"",“id”:“e943482995ec3d42”,“levelName”:null},{“inputCount”:0,“outputCount”:1,“name”:“Once”,“behaviorType”:“logic.triggers.Once”,“x”:180,“y”:96,“group”:"",“id”:“e9440b8da2a9d243”,“resetOnLevelStart”:false},{“comp_x”:0,“comp_y”:0,“inputCount”:4,“outputCount”:4,“name”:“Label”,“behaviorType”:“logic.hud.Label”,“x”:540,“y”:-32,“group”:"",“id”:“e9458c6e2aef0946”,“text”:“0”,“textColor”:6407253,“fontName”:“oduda”,“scale”:10,“borderStyle”:“Outline”,“borderColor”:null,“borderSize”:1,“textAlign”:“left”},{“inputCount”:3,“outputCount”:1,“name”:“Switch”,“behaviorType”:“logic.logic.Switch”,“x”:360,“y”:-160,“group”:"",“id”:“e97632b4e2a15a47”,"_startVal":0}],“links”:[{“input_id”:“e97632b4e2a15a47i2”,“output_id”:“e9405f9b1d22424fo0”},{“input_id”:“e9415a17e3a03044i1”,“output_id”:“e9405f9b1d22424fo0”},{“input_id”:“e940add378d29340i0”,“output_id”:“e9415a17e3a03044o0”},{“input_id”:“e97632b4e2a15a47i1”,“output_id”:“e940add378d29340o0”},{“input_id”:“e9415a17e3a03044i0”,“output_id”:“e9416a4e1f074f47o0”},{“input_id”:“e940add378d29340i0”,“output_id”:“e9415a17e3a03044o0”},{“input_id”:“e9458c6e2aef0946i0”,“output_id”:“e9415a17e3a03044o0”},{“input_id”:“e9416a4e1f074f47i1”,“output_id”:“e9440b8da2a9d243o0”},{“input_id”:“e9415a17e3a03044i0”,“output_id”:“e9416a4e1f074f47o0”},{“input_id”:“e943482995ec3d42i0”,“output_id”:“e97632b4e2a15a47o0”},{“input_id”:“e9416a4e1f074f47i1”,“output_id”:“e9440b8da2a9d243o0”},{“input_id”:“e9458c6e2aef0946i0”,“output_id”:“e9415a17e3a03044o0”},{“input_id”:“e97632b4e2a15a47i1”,“output_id”:“e940add378d29340o0”},{“input_id”:“e943482995ec3d42i0”,“output_id”:“e97632b4e2a15a47o0”}]}}}

Here is the problem:
The filter checks how many keys are remaining. Since the filter outputs when zero keys are remaining, it outputs the number inputted to it, zero. The confusing part is that logic gates consider an input of zero as no input. So you would have to output from the filter to a number block with the number one, and output that into the logic gate to activate it. Like this:

1 Like

Or you could use a switch instead of a logic gate thats what i did in the code above. It a lot easier and more simple.

It wouldn’t really be simpler. Logic gates often make more sense than switches.

@johnpost No they don’t I delete like three behaviors and just added one switch they are so easy and i always use them for like everything. If you think switches are complex thats pretty sad.

And I added one single number block to make it work. It comes down to personal choice.

Anyway @MrVargas delete all the behaviors in your door sprite and paste the code above into it and it should work fine ok.

Ok but i got rid of 3 behaviors which makes it way less laggy. What would you rather do to your game add 1000 new behaviors for it to work, or take away 1000 and add 500 to make it work, i would take the 500 because it wouldn’t lag game ad much.

Also switches have a purpose. And this is the best example of were one should be at. Logic gates are for more complex things and should not be used for stuff this simple.

Again, it comes down to personal choice. Anyway, Mr. Vargas was wondering why his code wasn’t working as intended. Explaining the problem so he understands it in the future is a better option in my opinion than telling him to delete all his code and just paste in yours.