Locking mouse in center of screen

How can I force the mouse to stay in the middle of the screen in first person? I need to do this WITHOUT event ticks.

1 Like

Just hide mouse cursor, put same cursor in middle of screen. Do logic that reads mouse cursor location when mouse is free, and reads middle of screen when mouse is in center.

However this is quite strange behavior you want, can you explain what is reason for it?

1 Like

I add the same sort of need, when using first person with mouse used to click the UI, and right mouse drag to look around. So I needed to hide the mouse on right drag + center it to avoid being blocked at screen border.
But I was doing it in blueprint, and it was not so easy to do it correctly.
Often games do it otherwise, press a key (alt for example) to show mouse and click the UI, and otherwise get the normal fps behavior, certainly easier to do in unreal.

1 Like

I have a drying rack in a survival game I’m making and the player can hover over food and eat it/take it. The logic works by using the “Begin Cursor Overlap” event on the piece of meat and then showing the player the widget. Setting the position every frame using event tick caused it to glitch out. ALSO, I’d like to refrain from raycasts/line traces.

1 Like

But why?!

The logic works by using the “Begin Cursor Overlap"

This is already performing a trace you’re trying to avoid, but worse.

2 Likes

Now that I think of it it would probably be the best option, but, how can I check if the raycast hits air? So the prompt disappears when the player isn’t hovering over the meat.

1 Like

Line trace returns a bunch of data, it will tell you when you’ve hit nothing - no blocking hit, or no component, or no actor. Here’s the entire setup which also accounts for proximity:

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.