How to make a AND branch?

I want to create AND branch like ( if (function1 && function2){} ), I need to touch the object and press the E button to delete the object, but as I understand it in the branch, it is selected at least 1 true as OR

Hi @Waredun

The easiest way to resolve this is have a boolean that sets when overlap( and unsets when end overlap) then on the ley oress event just check for the boolean , if true destroy actor if false then do nothing

1 Like

You could technically do this:

…but my gut feeling is telling me we’re approaching it from the wrong end. Something like player input belongs in the player / controller. Hard to really tell what you’re up to, though.

Are you going to implement this script in every object in the game? Normally you’d script interaction like that in the player BP, once.

You’ll have to find a way to check whether both are true without any input variables.
How would you check whether the E key is down?
How would you check if box is colliding something?

Click triangles to reveal answers

How to Check E Key

To check whether the E key is down, the easiest way with base inputs (not using the enhanced input system) would be to have a boolean that is changed.

How to Check Overlapping

There are two easy ways to check whether an object is being overlapped.
You can either use the same boolean strategy with begin and end overlap:

or you can check directly whether it’s overlapping something. We first get all the actors the box is overlapping, and then we check if the returned list (array) is not empty. If it’s not empty, that means there’s at least one overlapping actor:

Complete solution

We can then simply check whether both conditions are true.

This method allows you to hold down E and it’ll delete every object you overlap with, but if you want it one at a time you can disconnect the line from overlap:

As @Everynone mentions, the key input part should probably be handled once in the player. I would suggest watching a tutorial that covers interaction systems. Something like this one.
You can just use the solutions I’ve shown, but instead of having it be the E key, have it be the Interact event.

Thanks for your reply. And yes, I agree with you that adding a script to each item is not the best idea, but I kind of understood that you can make references to an object and your suggestion in order to add this script to the controller is logical. I just wanted to do something like an item matching system, but I haven’t fully figured out the Blue Print yet.


Thank you very much for this answer