Yet the result is this, the crosshair is offset diagonally according to the mouse cursor.
(The cursor is where the X is, I couldn’t capture it)
Thanks for any help
I did try this one before and tired it again. The result is the same except this time, the distance between the actual cursor and the widget varies as I move the mouse around.
Hey people, I’ve set up these nodes in order to make a crosshair point follow my mouse:
How is this supposed to work? Are we tracing something in the world? Is this why you’re getting projection involved? Asking as I do not not understand the intent. The mouse is not in 3d world. You can project it using direction from the camera and the then convert back to 2d but I don’t think that’s what is needed.
If you’re doing this full screen, you might be able to get away with:
Actually yes, I’ve only used the mouse example to make the situation easier to understand.
I have this canon’s turret that’s supposed to aim towards a certain world location, I tried to do so using these node. (the line trace is only for debugging).
I’m gonna be trying the possible solutions you’ve suggested in the morning but I just wanted to provide more context before I go.
Thanks for your time!
Do note that you may not need the canvas for this at all (one less widget to worry about). You can position a widget in the viewport directly. But a canvas may be useful for other things, of course.
or do we rotate the turret and it then aims along the barrel’s forward?
I’ve just found the solution accidentally and I don’t know why it works lol.
I only had to switch this node:
With this one:
This way I’d be forced to make the crosshair a widget of it’s own instead of merging it with the ui widget but I couldn’t find another option.
Thanks a lot tough
I did try this one again but resulted in the same outcome.
The approach I accidentally found works to some degree but there is a slightly annoying bug and I’d be grateful if you have any remarks.
Basically, my crosshair image is 10x10 but as I move the mouse around, the aspect ratio of the image also changes. Sometimes it’s 8x10 and sometimes its 8x8, 12x8…
I tried putting inside a SizeBox but that didn’t work either.
It’s a 2d image, how can it be? How are you testing this? Are you adjusting the image size, render scale? Is it wrapped in a scale box? One generally sets the size and that’s it:
Is there anything interesting in the widget hierarchy?
I’ve set the crosshair size to be printed out every frame and it indeed remains 10x10 the entire time, but to the eye, it looks like it does.
It’s hard to notice but It’s there: (ignore the color distortion, it’s just a bug in my gif generator)
Excuse my stupidity but I tried it before and this is what I get:
Should I set the entire widget to only take up 10x10 instead of 1920x1080? How do I do it?
Nah, it’s fine. It’s preview. To get more accurate representation:
The above does not change anything - but instead demonstrates how a widget would look like if its dimensions were 10x10. Quick way to iterate through layouts. Otherwise the editor defaults by stretching that red blob full screen and 16:9 ratio.
If you want a 10x10 image in 1920x1080 but the viewport is only 1280x720, the 10x10 image will get smaller than 100px in total. We can’t have half or a fraction of a pixel as you scale down so things get fuzzy.
There’s a bunch of features to account for resolution / aspect ratio. Long story: