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);
}
}