Keypad with Line Trace By Channel?

Hi,

so, I’m trying to make a keypad that works with Line Trace By Channel, to make the game more “immersive”, because I don’t want to use 2D widgets or some sort of “press ‘X’ key to write password”. My goal is to make the player come closer to the keypad and just click the buttons to try to get the correct password. I almost did it, but I’m stuck at the final blueprint settings.

I’ve used this Keypad BP for the settings. This Keypad BP works with the “OnClick” Event, so each collision box have it’s number value. I tried to change the OnClick Event to OnComponentHit, but it didn’t work, perhaps because of the Interaction Interface.

The only thing that really works is when I add an Event Interact (from the Interaction Interface, to connect the First Person BP with the Keypad BP) and connect it with the “Write Number” function, but it only writes the SAME number to every collision. Every collision is detected perfectly, by the way, but I can’t figure out how to separate each collision to write it’s number.

Here’s my setup:

  • First Person BP with the Line Trace By Channel → Break Hit Result → Interact Interface

  • Keypad BP With 9 box collisions (each button)

  • Interact Interface to connect both BP.

GIF with the result I got until now: https://media.giphy.com/media/XhWCvEqRUEtPAWNNxF/giphy-downsized-large.gif


What’s handy with a line trace, is you get to tell the BP which component you hit

If you mod your interact BPI to allow passing the component, then you will be able to do it, I think…

1 Like

If these are the hitboxes the trace is hitting:

image

You could hardcode tags into those comps and pass a tag converted to text right into the interface. You could pull a tag from the component pin mentioned in the previous post. Or you can pass the entire comp, depends on what else needs to happen.

I presume these hitboxes are in an array. The keypad number is just the array index :smiley:

UE5 icons confuse me. Are these Key_* the hitboxes?

image

If I had 9 of something, I’d hardcode it. If I had 99, I wouldn’t.

Yes, hitboxes.

Array is the best answer :slight_smile: ( I think… )

Here’s what I meant:

A component tag hardcoded right into the hitbox so we know which one was hit - pass the text to the interface, append to a text block.

2 Likes

Ah, yes… :pray:

1 Like

Thanks a lot ClockworkOcean and @Everynone, I’ve done some different things, but with the same ideas as yours. I created the component tags on the Box Collisions and created a target into the First Person BP. When I Print Text/Print String, it detects every collision box and its component tags (1 to 9) perfectly.

After that, I tried to create a Text Output/String Output on the Interaction Interface, to convert the tag from the First Person BP to an Integer from the Keypad BP. This integer is from the function, it determinates the pressed number., but it didn’t work.