Dear experts,
I am spawning a default weapon for the main character in C++ but when I start playing the weapon is at location x 0 y 0 z 0. I am trying it to attach to the right hand socket:
void AAdventureCharacter::SpawnDefaultWeapon()
{
//check the default subclass
if(DefaultWeaponClass)
{
//spawn weapon
AWeapon* DefaultWeapon = GetWorld()->SpawnActor<AWeapon>(DefaultWeaponClass);
//get the right hand socket
const USkeletalMeshSocket* RightHandSocket = this->GetMesh()->GetSocketByName(FName("hand_rSocket"));
if(RightHandSocket)
{
//attach the weapon to the right hand socket
RightHandSocket->AttachActor(DefaultWeapon,GetMesh());
}
//set equipped weapon to the newly spawned weapon
EquippedWeapon = DefaultWeapon;
}
}
The character I am using is modular and consists of SkeletalMeshComponents and when I start playing I get this error: LogSkinnedMeshComp: Warning: GetSocketByName(hand_rSocket): No SkeletalMesh for Component(CharacterMesh0) Actor(AdventureCharacterBP_C_0)
I think somehow the
USkeletalMeshSocket* RightHandSocket
is not recognized. Is that correct?
Thank you, Peter