RealDocs

UGameplayStatics::TransformWorldToFirstPerson

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

Description

Transforms a world-space position into first-person view space, replicating the GPU-side morphing applied to first-person primitives. Use for spawning projectiles or effects at the visual position of first-person weapon geometry.

Caveats & Gotchas

  • This mirrors GPU-side first-person rendering transforms; the result only matches the rendered geometry if ViewInfo matches the exact camera used to render those primitives in the same frame.
  • Pass bIgnoreFirstPersonScale=true when spawning a full-size world projectile so it launches from the weapon's visual barrel position without inheriting the perspective-scaling shrink applied to first-person meshes.
  • Added in UE 5.5; projects targeting earlier engine versions require a manual implementation or a version guard.

Signature

static ENGINE_API FVector TransformWorldToFirstPerson(const FMinimalViewInfo& ViewInfo, const FVector& WorldPosition, bool bIgnoreFirstPersonScale);

Parameters

Name Type Description Default
ViewInfo const FMinimalViewInfo& Camera parameters for the first-person view, including position, rotation, FOV, and first-person scale settings.
WorldPosition const FVector& World-space position to transform into first-person space.
bIgnoreFirstPersonScale bool If true, ignores the perspective scaling applied to first-person geometry; useful for spawning full-size world-space projectiles at a scaled first-person weapon's visual position.

Return Type

FVector

Example

Spawn projectile from first-person weapon muzzle C++
FMinimalViewInfo ViewInfo;
PlayerCamera->GetCameraView(0.f, ViewInfo);

FVector FirstPersonMuzzlePos = UGameplayStatics::TransformWorldToFirstPerson(
    ViewInfo, MuzzleWorldPos, true
);
SpawnProjectile(FirstPersonMuzzlePos, ViewInfo.Rotation.Vector());

Version History

Introduced in: 5.5

Version Status Notes
5.6 stable
5.5 stable Added

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.