How to Trace from screen mouse position to target in Blue Print

Hello, I’ve been combing over some posts for a way to trace from the screen mouse position to the target you are trying to click. I’ve come close but nothing seems to match the screen pixel to the actual target pixel I’m clicking on. The screen pixel appears to be easy enough to get using “Convert Mouse Location to World Space”. I’m a bit of a noob when it comes to vector math. Any takers on helping me understand the means in which to Blue Print a solution for finding the position/ vector from the screen pixel to the target. I’m using the 3rd person template so the camera is actual rotating behind the character.

This is where I’m at so far. All I’ve got is the mouse coordinates on the screen.

Okay so now I’ve made it here. This is getting me very close. It appears that the ray is always casting in the correct direction but it’s offset a little. Definitely not hitting the pixel out in the distance that I’m aiming at but I could certainly hit an object.

Here’s a shot of the traces. You can see how they angle inward towards the center of the screen. Am I reading this correctly, do the thick red blocks at the end of each trace indicate where the trace hit the environment out in the distance? Either way it’s coning inward/ outward and not landing perfectly on it’s target.

Hi, there is a special functional available in blueprint.

2 Likes

If you prefer to do that manually, start of the trace would be World Location pin in Convert Mouse location to Wolrd Space node, to get the end of the trace, multiply World Direction pin by some amount, depends on the length of the trace, then add World Location to resulting vector after multiplying. Hope this helps.

3 Likes