How do you center the mouse cursor?
So in my first person game I have a crosshair that's locked at the center of the screen and I also have a click event. The problem is the click event isn't activating when I move the crosshair over it, it only works when the mouse cursor is over it (which is invisible). So I'm trying to figure out two ways to solve this.
So how can I solve this problem?
UPDATE: So I made a line trace which is in my player controller class but it still doesn't work. It seems to do what it's supposed to do which is detect where my crosshair is but my click events continue to only detect when the mouse is clicking on the objects and not the crosshair. Here's the line trace blueprint:
UPDATE 2: Ok I put that blueprint in the hud class and it still doesn't work. How do I make it work? I'm starting to think I need a way for it to ignore the mouse cursor and only focus on the crosshair. So how do I make this work?
Can you share your solution?
answered Jun 02 '16 at 09:53 PM
World static is one issue. You should use a line trace not a box trace. Use a line trace by channel.
Secondly to set the mousecursor to the center of the screen use GetViewportSize break the vector2d structure (blue) and divide x and y by 2 that will give you the center of the screen. now you can use something like th efollowing but note it will onyl work on widgets (UMG aka the HUD or GUI so youd have to make an invisible widget.
If you download and install Ramas extra blueprints node plugin (google that) called victoryPlugin.zip on the wiki he has all sorts of extra BP nodes including the one on the bottomof the picture that does exactly what you want.
If this helped you clear stuff up or answer your question dont forget to select an answer so that people googling/searching the same question in the future know what helped you the most and can help them.
Heres some more you can do in the HUD class ONLY!
Lastly one thing I thought of in someone who asked something similar is to lock the cursor using the lock mouse or lock cursor or whatever node when it hits the vector2d x,y of the screen center
Follow this question
Once you sign in you will be able to subscribe for any updates here