AActor::K2_GetRootComponent
#include "GameFramework/Actor.h"
Access: public
Specifiers: UFUNCTIONBlueprintGetterinline
Description
Returns the actor's root scene component. This is the Blueprint-accessible getter for the RootComponent property.
Caveats & Gotchas
- • In C++ prefer GetRootComponent() directly — K2_GetRootComponent() is the Blueprint getter generated by the UPROPERTY macro and exists only to expose RootComponent via Blueprint. Both return the same value.
- • The return value can be null for actors that have not had a root component set (e.g. a plain AActor subclass with no component added in the constructor).
Signature
USceneComponent* K2_GetRootComponent() const Return Type
USceneComponent* Examples
Hide the actor's root component on BeginPlay
Blueprint
Get root component in C++ C++
// In C++ use the direct accessor:
USceneComponent* Root = GetRootComponent();
if (Root)
{
Root->SetWorldLocation(NewLocation);
}
// K2_GetRootComponent() is used internally by Blueprint nodes only. See Also
Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?