很抱歉,但是我的英语说得不好。
我的.h:
UFUNCTION()
void AttachToPlayer(USkeletalMeshComponent* Mesh, const FName &SocketName);
UFUNCTION(Server, Reliable, WithValidation)
void ServerAttachToPlayer(USkeletalMeshComponent* Mesh, const FName &SocketName);
virtual void ServerAttachToPlayer_Implementation(USkeletalMeshComponent* Mesh, const FName &SocketName);
virtual bool ServerAttachToPlayer_Validate(USkeletalMeshComponent* Mesh, const FName &SocketName);
我的cpp:
void ABagPlayer::AttachToPlayer(USkeletalMeshComponent* Mesh, const FName &SocketName)
{
if (Role == ROLE_Authority)
{
GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Red, TEXT("TEST"));
}
else
{
ServerAttachToPlayer(Mesh, SocketName);
}
}
bool ABagPlayer::ServerAttachToPlayer_Validate(USkeletalMeshComponent* Mesh, const FName &SocketName)
{
return true;
}
void ABagPlayer::ServerAttachToPlayer_Implementation(USkeletalMeshComponent* Mesh, const FName &SocketName)
{
AttachToPlayer(Mesh, SocketName);
}
我不明白为什么,当我的客户端启动功能“ AttachToPlayer”时,未调用功能“ ServerAttachToPlayer_Implementaion”。 但是,如果是服务器调用“ AttachToPlayer”,则会调用函数“ ServerAttachToPlayer_Implementaion”。
我尝试了很多事情,我正在拔头发!
感谢您的帮助