AActor::GetRootComponent
#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
Accessing the root component C++
USceneComponent* Root = GetRootComponent();
if (Root)
{
FVector WorldLocation = Root->GetComponentLocation();
} Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?