Hello Pr0t0Ss12,
After taking a look at your thread I was able to create a quick example to get you started in the right direction. I hope that this information helps.
Example:
Here I have created a new widget with two images in it. One will be used to follow the mouse (the green one) and the other is simply a background to make the 3D widget component easier to see. I set the image’s alignment to be (0.5, 0.5) so that it centers itself on the mouse’s point.
Here I have created an actor blueprint and I have added a widget component to it. From there I set the draw size to that of my widget (1920 by 1080) and I have set the pivot point to 0,0. The pivot change will be needed so that the actor location becomes the top left corner of the widget component (screen position is calculated form the top left corner to the bottom right). This will allow us to use the widget components relative location to determine where exactly the hit location is in relation to the widgets surface.
Here I have used the first person character blueprint to interact with my widget. I added a widget interaction component. I increased the interaction distance for easy testing. I also set the interaction source to “Mouse”.
From there I get the hit result from the widget interaction component. This allows me access to the hit location and the actor (3Dwidget) location. I convert the hit location to a relative location as it relates to the 3D widget. Once I have the relative location. I vet the vector length of the x and y of the hit location. This give me the horizontal distance from the 3D widgets relative location (creating what will be the screen space equivalent of the X axis). I then combine this with the Z value of the relative hit location. This gives me the relative vertical distance (creating what will be the screen space equivalent of the Y axis). Once I have my Screen space position equivalents, I create a 2D vector to hold them and cast to the widget that is being used so as to set the position of the image.
Notes:
The math will have to be changed if the widget is scaled. You will need to adjust the “screen space” values by the same scale.
This setup will handle all changes in yaw but does not take into account pitch or roll. However, this is an example to get you started.
Make it a great day