This may sound stupid when you read it at first because - yes - a child’s parent is the parent.
But I am coming from a Unity background and it is actually not clear to me.
In Unity you cannot remove/detach/add a transform component to actors.
This is why I am often used to cache a transform instead of the actor and if needed to get the actor from that transform.
The parent of a transform component is guaranted to be the same during its life in Unity and it’s lifetime is as long as the actor’s lifetime.
This is something you’ll have a better understand for if you attempt to blueprint it - assuming you haven’t already.
I’m not 100% sure of what you’re asking, but the transform of the component relative to the root component of the actor will always be the same yes unless you change it.
Edit: I should also mention that UActorComponent (the component class) and AActor both derive from UObject.
Therefore they are related by their base class rather than using direct inheritance as evidenced by the inheritance hierarchy at the tops of these pages:
Edit 2: Think I understand what you mean now.
I think that _pTargetRootComponent.AttachParent will not work. I haven’t ever tried getting the original actor this way, but seeing as how the type of that variable is reported in the IDE as USceneComponent* it doesn’t seem possible. USceneComponent* can not be casted to an actor as evidenced by the following hierarchy:
There may be another member function that can help you.
Edit 3: RootComponent is also of type USceneComponent* so you don’t need to use & to get its address since it’s already a pointer.
Edit 4: The member function you’re looking for may be GetAttachmentRootActor(). It returns a pointer to the actor which owns the component.