How to convert a screen coordinate to a world location?

How to convert a screen coordinate to a world location?
Thanks.

Updates:
There is a way done this in Blueprints.
https://docs.unrealengine.com/latest/INT/BlueprintAPI/Game/Player/ConvertScreenLocationtoWorldSpac-/index.html

Is there an API done this in C++?

If you search for any blueprint function, you can find it in the c++ source.

For ‘Convert Screen Location to World Space’ search for ‘ConvertScreenLocationToWorldSpace’ and you’ll find:



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

1 Like

Thanks, I found another function in APlayerController that meets my need.


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

1 Like