How to trace from player to cursor?

I’m trying to trace from the player to the mouse cursor’s location to fire a weapon. I’ve got it mostly working however for some reason the raycast is only accurate when shooting directly up or down, also if the cursor gets too close to the player it does weird things. The raycast should go through the cursor location but its not.

One thing to note, in order to get my character to properly rotate towards the cursor I did something similar and for that I just had to add an additional 90 degree turn to make it accurate. However that doesn’t seem to quite be the case for this one.

My Setup:

The Problems (As you can see the cursor is way away from the raycast):

I had a similar issue once. It appears that “Convert Mouse Location to World Space” is taking the actual mouse location (like right next to the camera location) instead of where it would be if it would trace from the mouse to the level.

Fear not there is a solution and it’s called “Get Hit Result under Cursor”. It provides you with the hit under your mouse which in this case is right on the floor. The cast between your character and the location will be slightly downwards… you could fix that buy just using the same height which however in return might provide inaccurate results if your hover above environment or a rift.

I hope this already helps.

Cheers :slight_smile:

Awesome this looks like it’ll work the way I need it! I’ll have to mess around with it a little bit but using “Get Hit Result under Cursor” with the line trace seems to be giving me much more accurate results.