I’ve already tried to clarify this problem to others, but none of them did help, so i’ll explain it as much as i can.
Anyway, I’m making first person shooter. What I wanna do is when the bullets in clip are empty is to automatically reload the weapon. I have weapon component, 3person weapon and my character classes set up. When the player clicks the mouse I set up a timer, by which the weapon shoots. When the player release the mouth I clear the timer. And I have “ReduceAmmo” method, which runs every time the weapon shoots. Basically, I don’t have access in weapon component when is weapon shooting precisely. Here’s the Reduce Ammo method:
void AThirdPersonWeapon::ReduceAmmo()
{
if (!HasAuthority()) return;
if (Bullets == 0) return;
Bullets--;
ForceNetUpdate();
OnAmmoChanged.Execute(Bullets);
UE_LOG(LogTemp, Display, TEXT("DElegate Invoked in weapon!"));
if (Bullets == 0)
{
StopFire();
OnReload.Execute();
UE_LOG(LogTemp, Display, TEXT("On reload broadcasting"));
}
}
On spawn of 3person weapon in weapon component i bind these delegates to certain functions. OnReload runs Reload method of weapon component, which is Server RPC, then it runs NetMulticast RPC PlayReloadAnim. Here’s the code of it:
void UWeaponComponent::PlayReloadAnim_Implementation()
{
if (IsRunningDedicatedServer() || !MyPawn) return;
if (!ReloadMontageFPP || !ReloadMontageTPP)
{
UE_LOG(LogWeaponComponent, Warning, TEXT("One of reload montage assets wasn't set"));
return;
}
if (MyPawn->IsLocallyControlled())
{
MyPawn->PlayAnimMontageFPP(ReloadMontageFPP);
}
else MyPawn->PlayAnimMontage(ReloadMontageTPP);
Basically MyPawn is the character i talked about in the first paragraph. And the last thing is the mere PlayAnimMontageFPP method of my character.
void APlayerCharacter::PlayAnimMontageFPP(UAnimMontage* MontageToPlay)
{
if (!InnerMesh || !InnerMesh->GetAnimInstance() || !MontageToPlay) {
UE_LOG(LogPlayerCharacter, Warning, TEXT("In 'PlayAnimMontageFPP' some nullptr occured"));
return;
}
const float Length = InnerMesh->GetAnimInstance()->Montage_Play(MontageToPlay);
UE_LOG(LogTemp, Display, TEXT("Anim montage playing for: %.2f secs"), Length);
}
Inner mesh is the skeletal mesh of first person arms. In logs it never shows something like “Anim montage playing for 0.00 secs”.
So, here’s the question:
Why does anim montage of first person arms run only on clients and not on listen server?
Furthermore, why it doesn’t run on STANDALONE, but runs on clients?