Download

3rd person crosshair

Hello, is there any tips for creating the crosshair for a 3rd person?
The usual way to do it doesn’t really give a good result for me

96f9f9c7be977200fb352ff37d2fbdb5e4e17d33.jpeg

What’s wrong with this result? That it’s really close to the character’s shoulder? That’s a camera issue typical of 3rd person games. Most of them offset the camera a lot more to the side than you have it. Unless you want to make the crosshair off-center on the screen . . .

I think I understand your issue. This solution is valid if you want the crosshair to be centered on where the player is looking.
First, align your image to the upper left instead of the center. Next, rename the image component to something that makes more sense, for example crosshairHL3.
Then, click the checkbox next to it’s name on the upper right to make it a variable.
In your event tick, add code similar to this:
59bb9fc04086e224d5350e9ca7e43fffee8ed6c1.png
The “center distance” is the distance of the center point from the character. For example setting the center distance to 200 will center the crosshair on a point that is 2 meters in front of the character.
The “Slot as canvas slot” function should target your crosshair, so you should connect it to your crosshair variable that we made earlier.
Keep in mind that this centers the crosshair’s upper left corner, so if you want to center it completely you’ll have to take that into account and subtract half the crosshair’s width from the X coordinate and half the height from the Y coordinate.
Also, it would be better to first check if the “Return value” is true to avoid any errors.
Hope that helps,
suzi9spal

Thank you very much for the help,
well the initial position is so much better but now the crosshair doesn’t move according to the mouse movement
is that normal?

As long as you have the “Use controller rotation yaw” value checked in the character blueprint and you are calling the “Add controller yaw input” function it should move accordingly.
If you haven’t done the above, go into “Projects settings”->Engine->Input and add an entry under “Axis mappings”. Name it “Turn” for example and set the binding to “Mouse X”.
When you have done that you add turning functionality like this:


Turn rate is usually 45.
Don’t forget to set the “Use controller rotation yaw” value to true.

Edit:
If you mean the mouse movement worked before but not now, it could be that the widget is taking focus. In that case try setting the input mode to game only (“Set input mode Game-Only” function) and hide the cursor (“Set show mouse cursor” to false).

Happy new year,
suzi9spal