Attaching Spring Arm to Character fail

Recently I’m trying to split the connection between camera, spring arm, and character in order to attain more

flexibility

in my original design, the inter-class connection should looked like this:

(character class)<-(Spring arm class)<-camera

the arrow between indicates that these different actors(or character) are connected via AttachTo() function
(note that these are not components in same class, instead, they are in different class)

the code works fine when I’m attaching camera to Spring Arm class

However, there are some trouble while i’m trying to Attaching Spring Arm instance into character.
It ends that when I’m trying to attach the spring arm, it will result in camera being in wired location or rotation

the code is simplified as follows:

//attaching spring arm to character

m_CameraBoom->SetActorLocationAndRotation( m_ControllingCharacter->GetRootComponent( )->GetComponentLocation( ),
m_ControllingCharacter->GetRootComponent( )->GetComponentRotation( ) );


//if I delete this line of code, the camera will back to normal.

m_CameraBoom->AttachRootComponentTo( m_ControllingCharacter->GetRootComponent( ) );


//attaching camera to spring arm, set camera’s location & rotation to the tail of spring arm

m_Camera->SetWorldLocationAndRotation( m_CameraBoom->GetCameraAttachComponent( )->GetSocketLocation( m_CameraBoom->GetSocketName( ) ),
m_CameraBoom->GetActorRotation( ) );


//attach camera to spring arm, this line of code works great as long as the spring arm is not
attached to character

m_Camera->AttachTo( m_CameraBoom->GetCameraAttachComponent( ), m_CameraBoom->GetSocketName( ) );


I’ve stuck in this issue for a long time, hopefully anyone can give me a guideline.