How to use SetMasterPoseComponent() to send an animation Blueprint from a spawned actor, to the Spawning Instigator?

Relatively new to programming in C++ & UE4. Might have some trouble using the correct terminology. Apologies in advance.

I’m trying to make an FPS - to learn from mostly.

The way I want it to work is:

I Have a BP Character derived from a C++ Character with a Skeletal Mesh Component (The first person Arms).

I also have a BP Pistol derived from a C++ Weapon (AActor) class with a Skeletal Mesh component (The first person pistol).

I want the BP character to use the animation blueprint set in the Pistol BP.


I spawn the Weapon by having the Character class call SpawnActor & AttachToComponent.

I have tried SetMasterPoseComponent() on both the Arms & the Pistol. It only works as expected if I set the arms as the master.
Otherwise I get a warning, pretty much every tick (I have removed some of the path info from the error to make it more readable):

LogTick: Warning: While processing prerequisites for SkeletalMeshComponent BP_Pistol.Weapon[TickComponent], could use SkeletalMeshComponent BP_PlayerCharacter.ArmsMesh[TickComponent] because it would form a cycle.

If anyone has any idea on how to acheive what I’m after, or even where to look, I’d really appreciate it.

I have attached the code below - this is the version that gives errors.

CurrentWeapon = GetWorld()->SpawnActor <AWeapon>(Pistol, FVector::ZeroVector, FRotator::ZeroRotator, SpawnParams);
	if (CurrentWeapon)
	{
		CurrentWeapon->SetOwner(this);
		CurrentWeapon->AttachToComponent(FirstPersonArmsMesh, FAttachmentTransformRules::SnapToTargetNotIncludingScale, WeaponAttachSocketName);    
		FirstPersonArmsMesh->SetMasterPoseComponent(CurrentWeapon->WeaponMesh);

		}

	}

So I worked out what was going wrong. It wasn’t a problem with my C++ nor was it a bug. It was a bad call in my animation blueprint

In my animation blueprint, I was trying to get the Owner Pawn.

Instead I had to Get Owning Actor, and then Get Owner on that. This allowed me to go an extra link up the chain - to the player character (I assume) and grab the variables from that, to drive the animation.

I’m guessing the animationBP was connected to the master (the gun) and not the slave (the arms & character), so get pawn owner was returning null. I assumed they had the same Pawn Owner once I ran the game, because of SetOwner(), but obviously not. I’m sure I’ll have more problems down the line, but for now its working.

If anyone has trouble with this let me know, I don’t have the words to explain it, but I can try harder if someone needs me to.

EDIT: Nevermind. It isn’t working on any new weapon assets I have made. Only the first one… Looks like I will need to look into it more.