AActor::CalcCamera
#include "GameFramework/Actor.h"
Access: public
Specifiers: virtual
Description
Calculates the camera view point for this actor when it is the active view target. Override to implement fully custom camera logic without a UCameraComponent.
Caveats & Gotchas
- • The default implementation defers to any active UCameraComponent on the actor. If you override CalcCamera and return custom data, ensure you also set OutResult.bConstrainAspectRatio and OutResult.AspectRatio if your FOV or projection differs from the player's settings — otherwise the renderer may crop or stretch incorrectly.
- • CalcCamera is called every frame while this actor is the view target, even if the result hasn't changed. Avoid expensive computations here; cache intermediate results where possible.
Signature
virtual void CalcCamera(float DeltaTime, struct FMinimalViewInfo& OutResult) Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| DeltaTime | float | Time in seconds since the last camera update. | — |
| OutResult | struct FMinimalViewInfo& | Output structure to fill with the camera location, rotation, FOV, and other view parameters. | — |
Return Type
void Example
Fixed overhead camera for a strategy actor C++
void AStrategyCamera::CalcCamera(float DeltaTime, FMinimalViewInfo& OutResult)
{
OutResult.Location = GetActorLocation() + FVector(0.f, 0.f, 1500.f);
OutResult.Rotation = FRotator(-90.f, 0.f, 0.f);
OutResult.FOV = 90.f;
} Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?