
In blueprint I can add a new Scene component and drag it on the top of the default Scene Root to override it.
But how to do this in the C++?

In blueprint I can add a new Scene component and drag it on the top of the default Scene Root to override it.
But how to do this in the C++?
Like this:
.h
UPROPERTY(EditAnywhere)
USceneComponent* DefaultRoot = nullptr;
.cpp
// In Constructor
DefaultRoot = CreateDefaultSubobject<USceneComponent>(TEXT("DefaultRoot"));
SetRootComponent(DefaultRoot);
Result:

Create a Scene Componenet and set it the root componenet instead of attaching it.
RootComponent = MyNewScene;
Thank You Sir for the perfect solution, this solution solved the issue
Thank You Sir for the perfect solution, this solution solved the issue.
Both Solutions are perfect, I really appreciated
Main thing is the problem is solved
keep up learning