Can you explain what exactly is missing from the result of your line trace that you’re doing through code? Is the debug line not being drawn correctly? Also, what is being done in the blueprint from the “Out Hit” and “Return Value” pins?
sorry I should attach the screesnhot directly.
The left line trace (the square) is when I’m using linetrace from Blueprint, while the right line is from c++.
And I wonder what is the issue with my c++ linetrace that it does not show a square when hitting an acotr
Can you also post a screenshot of what is being done as a result of this Line Trace in your blueprint? Your original screenshot shows how the line trace is being done, but doesn’t show what it does after it hits a target as that part is cut off. This is probably the part that is drawing the square you want, but I would need to see this to let you know what is missing from your code version.
To get the square at the hit location, you should be able to call DrawDebugPoint() at Hit.ImpactPoint to draw it. The only difference other than that in your code compared to the blueprint’s code is that the blueprint uses GetWorldLocation of the actor instead of GetActorEyesViewPoint.