Why is OnClicked for my BP object working differently when mouse cursor is shown and when it is not shown?

So I have made a BP for a desk object to turn off/on when you click on it. When I set the show mouse cursor in my BP for the player controller, I can click on any part of the desk from any distance and it will turn on, but I do no like that I have to click and hold down the left mouse button to move the camera as one problem.
The main problem is that when I disable the mouse cursor I get the small red crosshairs and can move the camera driectly corresponding to mouse movement but for some reason the BP for the desk object becomes very specific where on the object you have to click on it to turn on/off. Why is this?
I have a picture below showing the that is roughly the area of where I have to click with the crosshairs. I want to be able to click on any part of it and turn it on from a distance with out setting the show mouse cursor in m BP for player controller.

Hey ddtapia.

How are you registering whether or not you are clicking on the desk? Are you using a raycast? It would help if you could show us your blueprint.

Hi Jonathon,

I am watching the blueprint as seen below when I am play the level in the editor.

How big is your collision box/capsule/etc for the desk? OnClicked checks to see if you’ve clicked on the actor’s collision box, so the main reason you’d only be able to click on that small area would be a tiny collision box (or one that is extremely offset from the mesh it’s attached to).

This is a picture of the collision for the static mesh i am using for the BP. Is this what you mean?

That collision box looks fine. That means the problem must be with the way you’re hiding the mouse cursor. Can you show me that blueprint?

Oh ok. Well I am not using any actual blueprint. I am using the basic MyCharacter BP for FPS. I have a BP for my player controller but all i do is just simply have the ‘Show Mouse Cursor’ disabled.

Oh! Okay, I’ve managed to reproduce your situation now. I’m looking into the issue.

Hey, ddtapi,

I want you to try something for me! While you’re in your game, hit the Windows Key (or shift+F11). That’ll make your cursor visible again. You’ll see that the cursor usually isn’t in the center, where you expect it to be.

The reason is that ‘hide mouse cursor’ literally just hides the mouse cursor. It doesn’t ‘hold’ the cursor in the center of the screen, which is what you’d expect when you see the red crosshair and don’t see the mouse. So when you see the crosshair over the desk, the mouse is probably off in the corner of your screen somewhere. That’s why it doesn’t work when you click.

That means, rather than the OnClicked node, you should do a Line Trace whenever you click Left Mouse Button. If the Line Trace collides with a Desk, then the desk is turned off or on. I think you’ll find that fixes your problem neatly.



Hi Jonathon,

Thank you I will try that! That makes sense though.

Hi Jonathon should I use a LIne Trace by Channel or for Objects?

Both work, with some small differences. The description you get by mousing over the nodes:

For Objects:
Does a collision trace along the given line and returns the first hit encountered.
This only finds objects that are of a type specified by ObjectTypes.

By Channel:
Does a collision trace along the given line and returns the first blocking hit encountered.
This trace finds the objects that RESPOND to the given TraceChannel.

Thanks Jonathon! I got it working now with the help of some Event Dispatchers too! I appreciate the persistent help, keep it up!

I’m glad to help!