How to line trace from the viewport in C++?

I wish to fire a linetrace thowards the point clicked in the viewport. Unity had a handy method for obtaining a ray from a scren point and then you could use that as the end argument of a line trace.

Unity method I mentioned:

Ah, perhaps you didn’t notice the tag, the question is C++ related. I’ll update the question to reflect that better.

If you want to linetrace in editor you need to do get editor world instance

In unreal actors have OnClicked event so dont need to setup ione tracing if you want , it requires conclusion on actor

I found that just as I replied to your answer but didn’t get around to test it before I headed outside. Anyway, thanks for confirming!

Convert screen location to world space

I gave the gist.
it does not matter if the solution is described via a flowchart or BP or some pseudocodes.

if you would search about the hint I gave you, you would certainly find

bool APlayerController::DeprojectScreenPositionToWorld(float ScreenX, float ScreenY, FVector& WorldLocation, FVector& WorldDirection) const;

And

 bool APlayerController::GetHitResultAtScreenPosition(const FVector2D ScreenPosition, const ECollisionChannel TraceChannel, bool bTraceComplex, FHitResult& HitResult) const 

On the internet

Cheers

https://answers.unrealengine.com/questions/115748/c-equivalent-of-convert-mouse-location-to-world-sp.html

Hello! All stuff can be found in PlayerController