Hey All.
I’ve been facing a kind of a weird problem for about a week while working on Tom Looman’s c++ example.
I have a player pawn class (SCharacter) derived from SBaseCharacter which derived from ACharacter. And a weapon class which derived from Actor class.
My problem is, when i call “PlayAnimMontage” on player pawn from weapon class, it is not replicated to the clients when running on dedicated server.
Clients can see their own animations.
Clients cant see others fire animations.
Both Player and Weapon classes are replicated.
Here is my code on SCharacter class and header;
UFUNCTION(NetMulticast, Reliable)
void MulticastSetFiring(UAnimMontage* FireAnimation);
UFUNCTION(Server, Reliable, WithValidation)
void ServerSetFiring(UAnimMontage* FireAnimation);
UFUNCTION()
void SetFiring(UAnimMontage* FireAnimation);
void PlayFireAnimation(UAnimMontage* FireAnimation);
void ASCharacter::MulticastSetFiring_Implementation(UAnimMontage* FireAnimation)
{
SetFiring(FireAnimation);
}
void ASCharacter::ServerSetFiring_Implementation(UAnimMontage* FireAnimation)
{
MulticastSetFiring(FireAnimation);
}
bool ASCharacter::ServerSetFiring_Validate(UAnimMontage* FireAnimation)
{
return true;
}
void ASCharacter::PlayFireAnimation(UAnimMontage* FireAnimation)
{
if (Role == ROLE_Authority)
{
SetFiring(FireAnimation);
}
else
{
ServerSetFiring(FireAnimation);
}
}
void ASCharacter::SetFiring(UAnimMontage* FireAnimation)
{
// try and play a firing animation if specified
if (FireAnimation != NULL)
{
GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Yellow, FString::Printf(TEXT("SetFiring")));
Super::PlayAnimMontage(FireAnimation, 1.f);
}
}
From my weapon class, i simple calling;
void ASWeapon::PlayAnimationOnPlayer(UAnimMontage* Animation, float InPlayRate, FName StartSectionName)
{
if (MyPawn)
{
if (Animation)
{
MyPawn->PlayFireAnimation(Animation);
}
}
}
Any Suggestions?
Thanks.