Download

Center mouse in viewport (locked)

Hi friends, the last step I need to finish my project is to center the mouse (lock) in the viewport by blueprint. My scene has got a FPS for realtime archviz.

I don´t need crosshair in player controller or any like this, only need to set the mouse position in X.640 and Y.360 always, but I dont found accurate information to made it.

I put a custom crosshair in my HUD, but I need the invisible mouse overlaped with it.

Does anyone know how to made it with blueprint?

Thank you.

What’s wrong with just hiding the mouse cursor?

you can see my problem in this video. I don’t found the mistakes (sorry for my programming). I hope someone can help me:

https://youtube.com/watch?v=cKn2amVpNSQ

You probably should show the problem that happens for the user playing the game first. I’m not going to watch a five minute video walkthrough of blueprints :slight_smile:

I did see that you’re not centering the anchor-flower on your buttons/text items before I gave up, though. The best default is to always drag the “flower” into the center of each widget you’re putting into your UI.
That may not help with whatever problem your game is having when being played (which we don’t yet know what it is) but is a good habit to get in.

The video is better now. The problem is showed at first :wink:

I think this is not a “mouse” problem, but a “picking” problem.

Don’t use the mouse for first-person, center-of-screen picking. If you want to pick the object in front of the camera, you should cast a ray from the camera, in the camera forward direction, and see what you intersect.

It is possible, but extremely difficult to me.

well, I modified the blueprint to change materials and everything works fine now. The only problem is to center the “not visible mouse”. Does anyone know how do this?

As jwatte suggested, you should use raycasting/line tracing rather than using the position of the cursor. Since it is a first person scenario, you can send a ray from the camera, along its forward vector.
Then you just have to cast this ray whenever you click, and it will pick the object in the center of the screen.

Of course, you’re right, but my blueprint works fine now and I think is easier to center mouse in viewport that modify the blueprints and player controller to adapte all to raytrace workflow (I can not do that).
There are many people searching how to center the mouse in Unreal, and Epic could answer them by a viedo or docs. You can see “Set mouse position” docs for example, and you will not find anything.

Can anyone answer this? I want to know how I would be able to center the mouse cursor ever time I show or hide it?