Click events not working when the mouse cursor is shown

I currently have a first person game and I wrote a simple function that shows the mouse cursor in game.

The problem is that whenever I click the mouse when the cursor is shown, the game loses focus and click events no longer work. All I basically want is for the game to run exactly as if the mouse cursor is invisible. Does anyone know how to do that?

Try setting InputMode to GameAndUI

That doesn’t work. It seems that once the camera is locked, click events no longer work.

why do you want to trigger the click event while the mouse is being shown anyways?
I don’t think
there’s a way to trigger both touch and click events at the same time but you could

  1. add a transparent widget button on the screen when showing the mouse
  2. link that button click event to the click event you want

What I’m trying to do is have the player be able to freeze the camera so they can use the mouse to click an object in the game.

for that, my best guess is, you would need to trace from the camera into the world and check what actor you hit in the world, from there trigger the click event,

OK, so apparently I had the wrong idea. I think it would be better to do a line trace but with the cursor position. Right now, I’ve set up a line trace with the center of the screen so if the center crosshair is overlapped with the object and the “interact” button is pressed, the event triggers. Is there a way to do that with the mouse cursor position instead of the center crosshair?

yes you can trace from any individual pixel on the screen. Search for it online you will definitely find some tutorial