Hello all! Still new to C++ and Unreal as far as C++ goes.
I am trying to get the reference of a weapon to get a Static Mesh Component from it. I am able to spawn the weapon and attach it to my character within BeginPlay():
Super::BeginPlay(); TArray<USkeletalMeshComponent*> SKMesh; //Creates Skeletal Mesh Array = SKMesh AActor* ActorRef = GetOwner(); //Gets Actor Reference ActorRef->GetComponents<USkeletalMeshComponent>(SKMesh); //Appends Skeletal Mesh Array = SKMesh USceneComponent* SceneComp = Cast<USceneComponent>(SKMesh); //Get SkeletalMesh SceneComponent FActorSpawnParameters SpawnParams; //Sets Spawn Parameters static AWEA_Base* WeaponRef = GetWorld()->SpawnActor<AWEA_Base>(Weapon, FTransform(), SpawnParams); //Spawn Weapon and set Reference WeaponRef->AttachToComponent(SceneComp, FAttachmentTransformRules(EAttachmentRule::SnapToTarget, true), "weaponSocket"); //Attach Weapon to SKMesh Socket
However adding static to the variable “WeaponRef” does not allow me to use it within a function that I have declared in the same class. Any help here?