LineTraceByChannel and GetHitResultUnderCursorByChannel gives different results

Hi,

I’m trying to do some raycasting in a networked project. However I have an inaccuracy issue that I can’t manage to solve.

So here are my steps:

  1. Get the mouse screen position
  2. Convert them to world coordinates using DeprojectScreenToWorld
  3. Calculate the direction vector from the player camera, to the projected 3D mouse point we got in step 2
  4. Execute LineTraceByChannel and spawn a cone at the hit location point

However, it’s not accurate compared to the GetHitResultUnderCursorByChannel build-in function. I use it like this and it works perfectly.

Please take a look at the results screenshot. In RED the results of my custom raycasting. In BLUE the result of the build-in raycasting.

What is wrong here ?

Thanks for reading, best regards.

I found the issue ! I’m stupid though haha but thanks to my previous post here and @Mhousse1247 advice, I checked the PlayerController.cpp C++ code and found out that GetHitResultUnderCursorByChannel is throwing the ray 100.000cm away from the start point, while I was throwing it 20.000cm away. This explains the small difference between the results !

Have fun with UE4 <3