I spawn my primary and secondary weapon in game, i set the secondary to hidden on begin and that works. I have a weapon switching system so when the player presses 1 or 2 it will switch between the weapons toggling the primary or secondary hidden/visible. the problem is when switching between weapons the primary weapon does not go hidden but the secondary weapon works fine.
I have tried doing it on the client and server, just getting into replication.
void AFpShooterCharacter::Server_ChangeWeapon_Implementation()
{
if (CurrentWeapon == nullptr) { return; }
if (bCanChange) {
if (PrimaryAnimInstanceClass && SecondaryAnimInstanceClass != NULL) {
//If the current weapon is the Primary Gun it will switch to the Secondary Gun
if (CurrentWeapon == PrimaryWeapon) {
PrimaryWeapon->SetActorHiddenInGame(true);
SecondaryWeapon->SetActorHiddenInGame(false);
Mesh1P->SetAnimInstanceClass(SecondaryAnimInstanceClass);
CurrentWeapon = SecondaryWeapon;
//If the current weapon is the Secondary Gun it will switch to the Primary Gun
}
else if (CurrentWeapon == SecondaryWeapon) {
PrimaryWeapon->SetActorHiddenInGame(false);
SecondaryWeapon->SetActorHiddenInGame(true);
Mesh1P->SetAnimInstanceClass(PrimaryAnimInstanceClass);
CurrentWeapon = PrimaryWeapon;
}
bCanChange = false;
GetWorldTimerManager().SetTimer(TimerHandle_ChangeWeapon, this, &AFpShooterCharacter::SetCanChange, 1.0f);
} else {
UE_LOG(LogTemp, Error, TEXT("Missing a weapon Anim class for the player character"))
}
}
}
Gif : https:///635643d9d0ec9f2d52e26460a3a2b13f