Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

LineTraceByChannel and GetHitResultUnderCursorByChannel gives different results


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

alt text alt text

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

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. alt text What is wrong here ?

Thanks for reading, best regards.

Product Version: UE 4.14
more ▼

asked Nov 24 '16 at 12:32 PM in Blueprint Scripting

avatar image

692 32 22 56

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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

more ▼

answered Nov 24 '16 at 12:54 PM

avatar image

692 32 22 56

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question