Converting a Skeletal Mesh Component to Scene Component?

Hello everyone!
I am having an issue figuring out where to go from here with my code. I am spawning a weapon, and trying to attach it to an actors Skeletal Mesh Component.
I have an Actor Component called AC_WeaponHandler that is a child of my actor.

AC_WeaponHandler.cpp:


  AActor* WeaponActor = GetWorld()->SpawnActor(Weapon);                   //Gets Weapon Reference
    AActor* ActorRef = GetOwner();                        //Gets Actor Reference
    TArray<USkeletalMeshComponent*> SKMesh;                     //Creates Skeletal Mesh Array
    ActorRef->GetComponents<USkeletalMeshComponent>(SKMesh);                     //Appends Skeletal Mesh Array SKMesh
    WeaponActor->AttachToComponent(NEEDMESHHERE,FAttachmentTransformRules (EAttachmentRule::SnapToTarget, true), "weaponSocket");           //Attach Weapon to SKMesh Socket

I know that I cannot directly access the mesh from the array and it needs to be specifically assigned to a variable, and then passed to “NEEDMESHHERE” However the syntax for AttachToComponent() requires a USceneComponent and not a USkeletalMeshComponent. When I pull the mesh from the array, how can I convert it to a scene component? Or am I going about this all wrong? I have been researching this for a day and most of the ‘solutions’ I found did not work, as the syntax must have changed since when the solutions were posted. I have come to the above code mostly by looking at the code from within the definition in VS. Also I am relatively new to C++. Been messing with it on and off for a few years.

As it turns out, this question was asked 4 days ago… How to convert USkeletalMeshComponent into USceneComponent? - C++ Gameplay Programming - Unreal Engine Forums
Heh… Here is my new code if it helps anyone!


    AActor* WeaponActor = GetWorld()->SpawnActor(Weapon);  //Gets Weapon Reference
    AActor* ActorRef = GetOwner();   //Gets Actor Reference
    TArray<USkeletalMeshComponent*> SKMesh;  //Creates Skeletal Mesh Array
    ActorRef->GetComponents<USkeletalMeshComponent>(SKMesh); //Appends Skeletal Mesh Array SKMesh
    USceneComponent* SceneComp = Cast<USceneComponent>(SKMesh[0]);
    WeaponActor->AttachToComponent(SceneComp,FAttachmentTransformRules (EAttachmentRule::SnapToTarget, true), "weaponSocket"); //Attach Weapon to SKMesh Socket

You don’t need to do any casting, A SkeletalMeshComponent IS a Scene Component because it inherits from it.