I have a problem with my code to attach a blueprint weapon to a socket on my character , it attach the weapon to the mesh but not the socket position .
void AScar::BeginPlay()
{
//Create a pointer on the character
ACharacter *player = UGameplayStatics::GetPlayerCharacter(GetWorld(), 0);
//Attach this object to the player mesh with Socket position
AttachRootComponentTo(player->Mesh, FName("weaponSocket"), EAttachLocation::KeepRelativePosition);
}
I tried all Attachlocation enum , but it didn’t change anything
Oh my bad , i found the problem when i use SnapToTarget there was a bad rotation offset from the socket, i didn’t realise it with the truefps camera , here is the solution : check your socket rotation , and the code is :
void AScar::BeginPlay()
{
// create a pointer on the player character
ACharacter *player = UGameplayStatics::GetPlayerCharacter(GetWorld(), 0);
// snap to the socket
AttachRootComponentTo(player->Mesh, FName("weaponSocket"), EAttachLocation::SnapToTarget);
}