Being able to walk while using HUD elements (e.g. a Button)

Hi there!

Iam currently on the mission to program an interactable HUD with Buttons into my First Person shooter.

What it’s supposed to do:
When pressing and holding F the Hud (Containing multiple Buttons) and Mousecursor appear, the player character is and should still be able to move (WASD), but the camera movement (Mouse look input) is and should be disabled.
The Player should be able to click the Buttons in the HUD, while still holding the F key, the HUD should only go away when the F key is let go.

Now the last part throws some issues that iam not able to solve. Either the HUD closes after I click one Button or i have to click a Button twice to let it register. Besides that after clicking a button and letting go of the F key i basically have to “tab back in”, the game doesnt resume as normal. Same Feeling with “Tabbing in to the HUD”
And if that wouldnt have been all, sometimes when i click the button, it glitches and starts to flicker like crazy. (Sadly didnt get to reproduce it)

Basically i just want to be able to smoothly interact with buttons on a HUD while holding down the F key and resume the first person shooter right after letting go.

If someone has some advice, please let me know!

Some Screenshots of my Code:
(Sadly some of it is in German)

This is the code for pressing F:

The function ToggleCameraMovement included in it:

How the Widget that is being added is looking like:

How it is looking like in game:

A little gif to elaborate the “unsmoothyness” ingame:
Animation3
Aiming in and wiggling left right was right after i clicked rightclick to “tab back in”, couldnt move the view otherwise

Let me know if something else is needed, thank you very much in advance to anyone interacting with this!

Have a nice day!

Hello @Shykaro ,

do you already set your input mode to game and UI? if you haven’t I think you should put it when you want to interact to the HUD and you can set it back to game only after the HUD is closed. You can do this in your ToggleCameraMovement.

If after doing this there still a problem, please reply

1 Like

Hi there!
When i last tried this i had the flickering bug i think, so i went back to not using it, but…

It actually works like a charm now. Thank you so much!!
Smooth and as intended.

Final code:

1 Like