How do i interact with a checkbox?

Hi! I have been trying for days to solve the following problem:

I want to interact with a checkbox by using the center of the camera from a first person point of view, specifically when pressing the “E” key.

So far I created this logic into the FirstPersonCharacter blueprint:

Then i created an Actor blueprint with a Widget Component which class is an User Interface Blueprint with a checkbox.


Then, i created and instance of the Actor in the world, which i want to interact with:


I’m very new to programming and i’m still learning my way through with this. I tried exhausting all sources of information before posting, but so far i haven’t been able to solve this seemingly simple yet horribly complicated task.

What am i doing wrong?
Is there anything i’m missing?

Thank you in advance!

Are there any errors? If so, what are they? What does the current output look like? How do you want the output to be?
I see that you interact with the actor from the player, but we need more info to help you out.

Please note that we don’t really spend so much time analyzing it one by one, so make it compact, direct and easy for us to understand it.

That line trace probably isn’t hitting the actor. End location should be the forward vector multiplied by a float (to define how long the line should be) then added to the start location.

If it did hit, the toggle event on actor would never work because it can only set checked to true if it’s already true.

Likewise, the widget event would only set it to checked because the set node doesn’t have anything plugged in to tell it to do otherwise.

You need a Widget Interaction Component instead of line trace by channel.


Also, never use Get All Actors of Class unless you absoutely must do something to every actor at the same time. The apropriate actor referenece can be obtained from the OutHit struct of the Line Trace node.

I made it work!
Interestingly, i didn’t have to use OutHit pin nor a Widget Interaction Component.
Here are the screenshots:

BP_FirstPersonCharacter

Actor_BP

Widget_BP

TEST

Thank you all for your support!

This will stop working correctly as soon as you have 2 checkboxes.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.