I didnt test this code but can you please try this and report back?
// ACharacter.h
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Gameplay)
class UAnimMontage* FireAnimation;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = WeaponUsage)
class USoundBase* FireSound;
UFUNCTION(NetMulticast, Reliable)
void MulticastSetFiring();
UFUNCTION(Server, Reliable, WithValidation)
void ServerSetFiring();
UFUNCTION()
void SetFiring();
protected:
void OnFire();
// ACharacter.cpp
void ACharacter::GetLifetimeReplicatedProps(TArray< FLifetimeProperty > & OutLifetimeProps) const
{
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
}
void ACharacter::SetupPlayerInputComponent(class UInputComponent* InputComponent)
{
// set up gameplay key bindings
check(InputComponent);
InputComponent->BindAction("Fire", IE_Pressed, this, &ACharacter::OnFire);
}
// WIP - Only Server can see animations of clients.
void ACharacter::MulticastSetFiring_Implementation()
{
SetFiring();
}
void ACharacter::ServerSetFiring_Implementation()
{
MulticastSetFiring();
}
bool ACharacter::ServerSetFiring_Validate()
{
return true;
}
void ACharacter::OnFire()
{
if (HasAuthority())
{
SetFiring();
}
else
{
ServerSetFiring();
}
}
void ACharacter::SetFiring()
{
// try and play the sound if specified
if (FireSound != NULL)
{
UGameplayStatics::PlaySoundAtLocation(this, FireSound, GetActorLocation());
}
// try and play a firing animation if specified
if (FireAnimation != NULL)
{
// Get the animation object for the arms mesh
UAnimInstance* AnimInstance = Mesh1P->GetAnimInstance();
if (AnimInstance != NULL)
{
AnimInstance->Montage_Play(FireAnimation, 1.f);
}
}
}