Hey, like the title says I’m having trouble calling a server function from C++. The thing is that the same setup on blueprints works.
This is the test setup on BPs: a normal function TestAuthority is called which checks for authority. If it doesn’t have authority it calls a function ServerPrintString that calls TestAuthority again, but from the server. Since now it’s being called on the server the switch redirects the execution toward the correct branch.
And this is the C++ code. The client does get inside the Role < Authority branch so the check is fine, but the function doesn’t do anything.
virtual void StartFire(uint8 FireModeId);
UFUNCTION(Reliable, Server, WithValidation)
void ServerStartFire(uint8 FireModeId);
void AAuWeapon::StartFire(uint8 FireModeId)
{
if (GetAuOwner()->Role < ROLE_Authority) {
// The client gets here, so I assume the function is being called but it's not doing anything.
ServerStartFire(FireModeId);
}
StartFiringSequence(FireModeId);
}
bool AAuWeapon::ServerStartFire_Validate(uint8 FireModeId)
{
return true;
}
void AAuWeapon::ServerStartFire_Implementation(uint8 FireModeId)
{
print("ServerStartFire()");
StartFiringSequence(FireModeId);
}
Any kind of advice would be appreciated. Thanks!