I want to be able to just hover over an object to click it rather than using a trigger area. Is this possible to do? I have multiple buttons close to each other in the game so using proximity triggers won’t work.
Hello @Impudent_Swine ,
In case this video doesn’t help, I’ll leave you a few questions:
Do you have any reference from a game that already does this, to understand it better? I also wanted to ask if you’re planning to do it in first or third person, and which version of Unreal you’re using.
I already have blueprints that do what the poster of the video did. To clarify my circumstances:
I have buttons that are very close to one another in a room, but the player sits in the middle of the room like FNAF and doesn’t move. It is a 3d game. I can press the buttons with the trigger blueprint, but the problem is that the player does not move, so the all the trigger spheres overlap with one another and press all the buttons at the same time. I don’t want that.
I want to be able to press the buttons with the player sitting in one spot, but I am wondering if this is even possible in a 3D game. Using the mouse button to control the buttons is the core of my intended gameplay.
This game is a perfect example of what I am trying to achieve. The player can click buttons that are right next to each other but I can’t get the triggers to work properly.
Here is a photo of the buttons. I made the triggers large enough to reach the player so they can hit the buttons, but this just results in both buttons being pressed at the same time, or not at all if the trigger is too small. I want to be able to highlight and select each individual button, even if the triggers overlap.
the video is a basic interaction with a linetrace from the center of the screen, if u wanna use the mouse u need the hit under cursor, so u dont need that big triggers ![]()
So after some tutorial watching I understand how the nodes work but now I need to get them to work with the player object. I connected them to a blueprint interface for interaction but the buttons are not pressing.
Hi again @Impudent_Swine ! Okay, I understand what you’re trying to do, so here’s a solution that might work for you.
First, create a base Blueprint called BP_Interact, which will serve as the parent class for any actor you want to make interactable. Inside this Blueprint, add a function called Interact and a boolean variable called bIsLookingAt.
Then, for every actor you want to be interactable, in this case I created two buttons with logic that changes their color when interacted with, go to Class Settings, set BP_Interact as the Parent Class, and enable “Show Inherited Variables” so you can see the inherited variables.
In the actor, you’ll call the Interact event (the one created in the parent), and if IsLookingAt is true, you execute whatever logic you want.
Button A
Button B
You can also create a simple widget, something like “Press E to interact”
Which you’ll show or hide from the Player Controller when needed.After creating the widget, promote it to a variable and add it to the viewport.
Then in your BP_FirstPersonCharacter, set up a Line Trace by Channel. The value you multiply by the forward vector determines the maximum interaction distance(Also keep in mind that the box/sphere collision in your actor should have a range similar to the line trace). If you want to visualize the trace while testing, activate one of the options under Draw Debug Type, and disable it once everything works.
After that, add the following logic.
You could also use Get Hit Result Under Cursor, as mentioned above,
but it’s not ideal for this situation(but I’ll leave it like this so you can test it in your project), for that to work you’d need to enable “Enable Mouse Over Events” in the Player Controller.
Lastly, when you press E, if CurrentInteract is valid, the Interact function gets called
With this setup, you should be able to interact with your buttons correctly, even if they’re placed very close to each other and if you have any questions about the logic, feel free to ask.
Hope it helps!
There was no need to go through all this effort for me so thank you. Since you made this, I have most of it down but the button still doesn’t press as I think I am missing a minor detail or node somewhere.
So here’s my code related to camera movements and functionality for the player
I don’t know if this is the problem though, and while I copied the cast to player nodes at the end, it looks like those were only to show the widget for the interact button (which I won’t need) so I will just disconnect the one giving the warning (unless that somehow is related tot he problem >.>)
This is my button code which I think IS what’s wrong
I put the AND boolean nodes in the way you had them, and then added the “NOT” boolean which is what I was using as part of the code before, but neither worked. I know the code looks messy but that’s because my button does three different things: turns on a spotlight, animates with a timeline, and lights up with an emission texture when pressed. I also added the overlap components and parented the BP_Interact but nothing happens when the button is pressed.
No worries ,as long as I can help you, it’s all good. First of all, I see there are some nodes in your blueprint that aren’t set up correctly
You should have it like this
then if you dont want to have an interface you can set the code like that
on branch false and on cast fail conect the is valid node and at the end you have to set the current Interact(It should look like the one above)
you dont need this code in the player controller, so you can delete it
And for the button code, if I understood correctly what you’re trying to do, try this. You don’t need so many Branch nodes or the Sequence , a FlipFlop should be enough
Let me know if it works!
I don’t get what I am doing wrong lol. I did everything exactly the same as you but the button never clicks as though the interaction isn’t happening at all. Clearly it is something I am doing wrong.
EDIT: Hold up. So I think it may be a problem with my collision settings. MAYBE. I tried changing the collision from OverlapAllDynamic to BlockAllDynamic and I think it started somewhat working because the false condition string was popping up, a red square appeared in the middle of my screen when the cursor went near the button, and the collision box sent me to north africa because I had it set to 500 meters.
I’m going to try different collision settings to see if I can get the button to be interactable as I suspect it is a visibility problem, but I’ll test some more.
EDIT 2: I should also clarify that the player is sitting still during the course of this game. I know that with collision triggers, they require being outside of them and then walking into them, whereas spawning inside of them does not trigger them, so I think that is relevant to clarify.
In the event graph, whenever I try to click the button, the branch always returns the false value, triggering the string print.
Here is the button graph.
So I added a “not” boolean node as I did in my original button code since that switches the true/false value and caused the branch node to return the “true” value, but now the problem is that only the first set of nodes work which control the lit up texture. I’ll have to look through my blueprints and graphs because moving the nodes around did not make the spotlight or timeline work, which seems to indicate a problem somewhere else. The emissive texture trigger works as normal.
Sorry to double post but I didn’t want to just keep editing the same post and blowing it up. I can see what the problem is. The booleans connected to the branch don’t work.
I’m just lost, though. Everything is connected in the same string of nodes but only one of them works. The button lights up but no matter how I position the other nodes, only the button emission texture change goes through.
If everything is properly set up in your First Person Character, try removing the other booleans and keep only CanInteract and IsLookingAt. Check if it works correctly after that
It is the same result. Only this part of the code works properly:
And this is my character blueprint which doesn’t seem to be the issue.
As stated before, the booleans not working is the problem, but I just can’t figure out why. After trying again just now, I removed all the booleans from the branch and the result was actually the same. The button lit up but nothing else happened, so it seems to be a problem with the boolean variables not being valid or recognized?
Okay, two things: first, you’re missing a Set CurrentInteract in your FirstPerson Blueprint
and second, on the Branch remove the extra pins, because otherwise you’re still adding a condition.
This is how it’s supposed to look
Let me know if it works
Thank you for continuing to assist and I understand if you decide to stop as the error is clearly on my end and I cannot figure this out for the life of me.
Update: Adding the nodes after the timeline seemed to make the button animation work. It was probably animating the moment I added the lerp and set relative location nodes but it was just too slight of a movement to notice, though I don’t recall that being the case before. So this leaves the spotlight, which makes sense as I need to properly reference it since it is a different actor, and I am pretty sure that that’s the problem.
Original: When I only have the CanInteract and IsLookingAt attached to the ANDBoolean, only the false value is returned no matter how many times I click, which is evidenced by “Chicago” repeatedly appearing. Now, something that wasn’t happening before: in the game, the red square, which I think indicates the vector field that allows my cursor to interact with the object when inside, moves to the side when I move the cursor up and down.
No worries at all, this is precisely how video games are developed! It’s all about a process of constant iteration.
The reason it was always printing out false for you is that it was only designed to work if you were within the collision range, it was my fault . If you want it to activate from anywhere simply by touching it, try using the following configuration:
Go to Project Settings and create a new Object Channel with the value of Block.
Although we are already checking to ensure interaction is only possible with certain actors, I think adding this will make it neater (more organized).
In your BP_Firstperson, use the Get Hit Result Under Cursor for Objects node
you can also use the one mentioned above, Get Hit Result Under Cursor by channel
Try whichever one you like best for your game.
- Then, in your button’s Blueprint, make the following modifications:
- On your Static Mesh, use On Begin Cursor Over and On End Cursor Over.
Change the Collision Preset to Custom and select the one you created previously.
Also remember to enable the “enable mouse over events” option in the player controller.
Now everything should work properly, Let me know if it works!!
By the gods, it works! So, the spotlight not working, I THINK, was the result of no longer using the Interface blueprint to connect to it, and as such having no direct reference to the actor which was separate from my button blueprint.
What I did to solve this was add a spotlight to my button blueprint and just drag it over as a variable which was an easy fix. Now, as something that is extremely annoying: while the main problem was in fact the whole click trigger system, it is possible the spotlight was working but I just didn’t see it because… my intensity units setting was set to “unitless” for some odd reason, so with my intensity node set to 100 when the light turns on, the light was invisible when pointing down the dark hallway.
As for the button trigger, the Get Hit Result Under Cursor gave the result I was looking for, thanks!
That’s great! Best of luck with your project. If you have any questions, feel free to ask again on the forum , it’s a great place to get help with anything you need!
Happy developing!!!
































