v4.7版本之后的定义方式:
如果函数定义为UFUNCTION(Server, Reliable, WithValidation),需要同时为其定义_Validate和_Implementation两个函数
头文件:
UFUNCTION(Server, Reliable, WithValidation)
void ServerMove(FVector Velocity, bool bSweep);
virtual bool ServerMove_Validate(FVector Velocity, bool bSweep);
virtual void ServerMove_Implementation(FVector Velocity, bool bSweep);
CPP文件:原函数名不用实现,但_Validate和_Implementation必须实现
bool ASWeapon::ServerHandleFiring_Validate()
{
return true;//默认返回为true
}
void ASWeapon::ServerHandleFiring_Implementation()
{
//具体的函数逻辑
}