I wrote a small pack of code, based on shooter game sample.
I setup my character, controller, camera, so I can walk around and watch my first person mesh or third person (in multiplayer for example).
The problem is there is something wrong with weapon, because they aren’t attaching nicely for first person mesh and I dont know why.
I tried to rotate weapon mesh its doesn’t change anything at all! I’ve attached several image examples… And I did try to change socket rotation it doesn’t change anything too…
So, code for my character is :
void APlayerCharacter::PostInitializeComponents()
{
Super::PostInitializeComponents();
FActorSpawnParameters SpawnInfo;
SpawnInfo.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
AWeaponItem* NewWeapon = GetWorld()->SpawnActor<AWeaponItem>(DefaultWeapon, SpawnInfo);
NewWeapon->EquipWeapon(this);
}
And for my weapon
void AWeaponItem::EquipWeapon(APlayerCharacter* Character)
{
FName AttachPoint = Character->GetWeaponAttachPoint();
MeshFPP->AttachTo(Character->GetCharacterMesh(true), AttachPoint);
MeshTPP->AttachTo(Character->GetCharacterMesh(false), AttachPoint);
}
It simple as hell and I checked several times that AttachPoint is right