So, here’s what’s going on:
When you multiply the World Direction by that insanely large number, it’s setting the end point of the trace far into the distance. And because this is a perspective camera, that point far into the distance no longer lines up with where the cursor is located on the screen. So how we do we solve this? 2 possibilities, depending on what you need specifically for your project:
-
You don’t multiply the World Direction by an insanely large number. Instead, multiply it by the distance from your camera to your character. This can be calculated manually or you can just use the spring arm length. This will keep the trace on the same plane as your character. Use this if you don’t intend to detect items in the background.
-
However, if you want to be able to trace to anything onscreen, use two line traces. The first one will use the World Location from the 'Deproject Screen to World" node as the start, and the end point will be (World Location + (World Direction * 10000)) Pretty much what you have now, but without breaking the vector to make a new one. The second line trace will be the same as the first possibility listed above, but will instead use the distance from the hit result of the previous line trace + 1 rather than the spring arm distance. The + 1 will ensure the trace actually hits instead of stopping just before. This will let you trace to anything that’s onscreen.
I hope this solves your issue.