Help with the AND gate

Ok, so I’m working on my game and I have this code that utilizes JR01’s “distance” bundle (disregard the fact that the bundle is named “Angle”, that’s just because I changed my mind about what to do with the bundle after naming it that) and an AND gate to tell when the enemy is at the same spot where it last saw the player. the “x” and “y” inputs are the last stored x and y value of the player that the enemy is tracking


The problem is that when the enemy is on the spot where it last saw the enemy, it activates the “fail” outputs on all of the filters seemingly at the same time, thereby activating both inputs of the AND gate at presumably the exact same time. But for some reason the AND gate still doesn’t activate. I’ve already thought of a way to do it without using the AND gate, but could anyone tell my why this doesn’t work, and maybe a way to make this particular method work using the AND gate? Because if the AND gate won’t work like this, isn’t it mostly useless? Or am I missing something fundamental?

1 Like

This is a bug that me and grazer went over a long time ago. Apparently since bundles are triggers, they can only send something through every 1/30 of a second, which apparently is my advanced logic gates I were making were not working at all. So yea, logic gates and bundle inputs do not mix.

2 Likes

Are you saying that you are sending the value “0” into all 4 inputs of those input filters at the same time, and the AND gates fail to output anything?

Usually when a logic gate has confusing behavior, it is because the inputs are not being activated during the same frame.

Also, it looks like you are viewing this object from the library and not a specific object, so that can also cause strange looking results since you can see the activity from every object. Try opening a single object in the level for more intuitive visualization.

3 Likes

The Gates are finicky, could you dm me a link to your game?

4 Likes

Looks like Maze Hunt, which chris submitted for the LevelUP Jam a while back.

1 Like

Yeah, it’s Maze Hunt

2 Likes

Yeah, the value “0” is going into the AND gates at the same time (the filters are both being activated from the same expression block, so they are definitely activating at the same time). The AND gates don’t output anything though. Also, I am looking at it from the library because this is the enemy object, which doesn’t actually spawn until the game starts (because everything is randomly generated), but it shouldn’t be an issue of seeing activity from “every” object because only one enemy is ever spawned. Unless the library view just inherently works differently even if there is only one of that object?

1 Like

Ok, I managed to get a screenshot of the behaviors actually activated (and it’s not library view either)


Aaaaannnd halfway through this message I realized I was an idiot and forgot how logic gates actually work. The AND gate only activates if it receives an “on” value (as in actual boolean operations). Sending "0"s into the inputs is the same thing as not sending anything at all, so it was not seeing it as an activated input. I altered the code a little bit such that now the “fail” outputs go to a “get” input on a number, which outputs a “1” into the inputs of the AND gate, and it works!!! So, apparently I’m just a lil bit dumb, lol. Thank you for your interest in this topic and for attempting to help anyway!! :slight_smile:

Screenshot of the working code in case anyone was curious:

1 Like