RealDocs

AActor::HasActiveCameraComponent

function Engine Since 4.0
#include "GameFramework/Actor.h"
Access: public Specifiers: virtualconst

Description

Returns true if this actor owns at least one active UCameraComponent. Used by the player controller when choosing a view target to determine whether to call CalcCamera on this actor.

Caveats & Gotchas

  • A UCameraComponent is only considered 'active' if its bIsActive flag is true. Cameras created but never activated (e.g. placed in editor but auto-activate unchecked) will not be detected.
  • The bForceFindCamera parameter bypasses the active-check and does a full component scan; use it sparingly because it iterates all owned components.

Signature

virtual bool HasActiveCameraComponent(bool bForceFindCamera = false) const

Parameters

Name Type Description Default
bForceFindCamera bool If true, search for a camera component even if the actor is not currently the view target. false

Return Type

bool

Example

Check before forcing a view target C++
if (SomeActor->HasActiveCameraComponent())
{
    PlayerController->SetViewTarget(SomeActor);
}

Version History

Introduced in: 4.0

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.