PS: The problem with reading a mouse click, is you aren’t reading anything about the player whereabouts. So it’s working perfectly.
And so, you have come to the next big question in blueprint interaction. There is a solution floating around youtube, which is easily understandable, but not great.
Put a collision box around your BP, and only allow interaction if the player is in the box. You can either do that by enabling input on overlap, or checking for overlap when the button is pressed.
The downside of this is a bit of extra programming every time you make an interactable object, and… you can open the door with your buttt.
The generally accepted ( and superior ) method, which only works when the player is facing the object, but takes more programming to get it off the ground, is a line trace and blueprint interfaces.
Basically, on mouse click, the player does a line trace to what’s in front of them. If there’s an object there, it sends a blueprint interface message saying, ‘hey, I interacted with you’, and the object can respond accordingly.
The list of benefits of this method, outweighs the buttt method by quite a long way, and includes:
You only have to get it working once, then you can interact with any actor
Err… number 1, but even more so, because you can call a BP interace on ANY actor, it just doesn’t have to respond.
It’s very easy to make it modular, all you have to do it write the response in the interactable stuff.
And so on, here’s a vid about interfaces and line traces: