RealDocs

UGameplayStatics::DeprojectSceneCaptureToWorld

function Engine Blueprint Since 4.12
#include "Kismet/GameplayStatics.h"
Access: public Specifiers: staticBlueprintPure

Description

Converts a UV coordinate in a SceneCapture2D render target into a world-space position and ray direction. Use to pick objects that appear in a minimap or security camera render texture.

Caveats & Gotchas

  • TargetUV is in normalized 0-1 UV space, not pixel coordinates — divide pixel coords by render target dimensions before calling.
  • The scene capture's FOV, aspect ratio, and projection mode must match the intended view for deprojection to be accurate; mismatches cause the ray to miss the expected world location.
  • Returns false and leaves outputs uninitialized if SceneCapture2D is null or has no valid capture component.

Signature

static ENGINE_API bool DeprojectSceneCaptureToWorld(ASceneCapture2D const* SceneCapture2D, const FVector2D& TargetUV, FVector& WorldPosition, FVector& WorldDirection);

Parameters

Name Type Description Default
SceneCapture2D ASceneCapture2D const* The scene capture actor whose view is used for deprojection.
TargetUV const FVector2D& UV coordinate in the render target (0,0) to (1,1) to deproject.
WorldPosition FVector& Output: world-space position on the near plane of the scene capture.
WorldDirection FVector& Output: normalized world-space direction through the given UV.

Return Type

bool

Example

Click on minimap render texture to get world location C++
// MinimapUV is the normalized (0-1) position clicked on the minimap widget
FVector WorldPos, WorldDir;
if (UGameplayStatics::DeprojectSceneCaptureToWorld(MinimapCapture, MinimapUV, WorldPos, WorldDir))
{
    FHitResult Hit;
    GetWorld()->LineTraceSingleByChannel(Hit, WorldPos, WorldPos + WorldDir * 50000.f, ECC_WorldStatic);
    MoveCharacterTo(Hit.ImpactPoint);
}

Version History

Introduced in: 4.12

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.