Hi, i’m try to do a FPS multiplayer, and i have a problem with AttachMeshToPawn from Weapon class.
void AAWBaseWeapon::AttachMeshToPawn()
{
if (MyPawn)
{
DetachMeshFromPawn();
FName AttachPoint = MyPawn->GetWeaponAttachPoint();
if (MyPawn->IsLocallyControlled() == true)
{
USkeletalMeshComponent* PawnMesh1P = MyPawn->GetMesh1P();
USkeletalMeshComponent* PawnMesh3P = MyPawn->GetMesh();
Mesh1P->SetHiddenInGame(false);
Mesh3P->SetHiddenInGame(false);
GetMesh1P()->AttachTo(PawnMesh1P, AttachPoint);
GetMesh3P()->AttachTo(PawnMesh3P, AttachPoint);
}
else
{
USkeletalMeshComponent* UseWeaponMesh = GetWeaponMesh();
USkeletalMeshComponent* UsePawnMesh = MyPawn->GetPawnMesh();
UseWeaponMesh->AttachTo(UsePawnMesh, AttachPoint);
UseWeaponMesh->SetHiddenInGame(false);
}
}
}
I use the same code like ShooterGame, but when i play with 2 players, only server have weapon first person mesh attach on hands, client are only hands without weapon
but in client window i can see the other player third person model.
The “MyPawn->IsLocallyControlled()” return true only in server window, but in clients window return false, Why?