RealDocs

AActor::GetRootComponent

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

Description

Returns the actor's root scene component, or null if none has been set. The root component defines the actor's transform in the world.

Caveats & Gotchas

  • Returns null for actors that have no scene component at all (e.g., a pure-logic AGameMode). Always null-check the result before dereferencing.
  • In Blueprint, the root component is accessed via the 'Get Root Component' node, which internally calls K2_GetRootComponent — a thin wrapper around this function. The C++ result is identical.

Signature

inline USceneComponent* GetRootComponent() const { return RootComponent; }

Return Type

USceneComponent*

Examples

Move the root component to a new world location on BeginPlay Blueprint
Event BeginPlay Set World Location Target is Scene Component Target New Location Sweep false Teleport false Get Root Component Target is Actor Return Value Make Vector X 0.0 Y 0.0 Z 100.0 Return Value Return Value
Edit Blueprint graph Move the root component to a new world location on BeginPlay
Drag node headers to move · Drag from an output pin to an input pin to connect · Scroll to zoom · Right-click for actions
Accessing the root component C++
USceneComponent* Root = GetRootComponent();
if (Root)
{
    FVector WorldLocation = Root->GetComponentLocation();
}

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.