RealDocs

UGameplayStatics::DeprojectSceneCaptureComponentToWorld

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

Description

Converts a UV coordinate in a USceneCaptureComponent2D render target into a world-space position and ray. Use when you have a component reference rather than an ASceneCapture2D actor reference.

Caveats & Gotchas

  • Functionally equivalent to DeprojectSceneCaptureToWorld but takes a component reference; prefer this variant when your code already holds the component to avoid an extra GetOwner() call.
  • TargetUV is normalized 0-1 UV space — divide pixel coordinates by render target resolution before passing in.
  • The component's TextureTarget must be assigned and the capture must have rendered at least once; otherwise the view parameters may be stale or zeroed.

Signature

static ENGINE_API bool DeprojectSceneCaptureComponentToWorld(USceneCaptureComponent2D* SceneCaptureComponent2D, const FVector2D& TargetUV, FVector& WorldPosition, FVector& WorldDirection);

Parameters

Name Type Description Default
SceneCaptureComponent2D USceneCaptureComponent2D* The scene capture component 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 capture component.
WorldDirection FVector& Output: normalized world-space direction through the given UV.

Return Type

bool

Example

Deproject a security camera component UV to world ray C++
FVector WorldPos, WorldDir;
if (UGameplayStatics::DeprojectSceneCaptureComponentToWorld(
    SecurityCamComponent, ClickUV, WorldPos, WorldDir))
{
    FHitResult Hit;
    GetWorld()->LineTraceSingleByChannel(Hit, WorldPos, WorldPos + WorldDir * 20000.f, ECC_Visibility);
}

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.