HasAuthority() vs Role == ROLE_Authority?

Hello,

This is my first post so I apologize if I fail to explain anything correctly.

I’ve noticed that in UE 4.24.1 the condition Role == ROLE_Authority works in PIE but fails when ran as a standalone game. The game starts up but the Pawn cannot move. As a quick solution, I’ve had to use HasAuthority() that seems to work in both PIE and standalone, but gives this warning:

LogNet: Warning: UNetDriver::ProcessRemoteFunction: No owning connection for actor

Has there been any changes to UE that cause this to happen? I’ve tried searching for the solution but have failed to find one.

Example code that will only work in PIE:

void AGoKart::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);

	if (Role == ROLE_AutonomousProxy)
	{
		FGoKartMove Move = CreateMove(DeltaTime);
		SimulateMove(Move);

		UnacknowledgedMoves.Add(Move);
		Server_SendMove(Move);
	}

	if (Role == ROLE_Authority && GetRemoteRole() == ROLE_SimulatedProxy)
	{
		FGoKartMove Move = CreateMove(DeltaTime);
		Server_SendMove(Move);
	}

	if (Role == ROLE_SimulatedProxy)
	{
		SimulateMove(ServerState.LastMove);
	}

	DrawDebugString(GetWorld(), FVector(0, 0, 100), GetEnumText(Role), this, FColor::White, DeltaTime);
}

Example code that runs in both PIE and standalone:

void AGoKart::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);

	if (!HasAuthority() || Role == ROLE_AutonomousProxy)
	{
		FGoKartMove Move = CreateMove(DeltaTime);
		SimulateMove(Move);

		UnacknowledgedMoves.Add(Move);
		Server_SendMove(Move);
	}

	if (HasAuthority() || Role == ROLE_Authority && GetRemoteRole() == ROLE_SimulatedProxy)
	{
		FGoKartMove Move = CreateMove(DeltaTime);
		Server_SendMove(Move);
	}

	if (Role == ROLE_SimulatedProxy)
	{
		SimulateMove(ServerState.LastMove);
	}

	DrawDebugString(GetWorld(), FVector(0, 0, 100), GetEnumText(Role), this, FColor::White, DeltaTime);
}

Thanks in advance.

I think they did make a change since recording that made this work differently.

I see. I will try and dig deeper for a different solution.

Thank you responding!

Maybe I misread your post. Is there an issue with the solution you outlined?

I apologize if I didn’t explain correctly.

The problem with the solution code is that it runs correctly in PIE and standalone but the console constantly gives off this warning as well:

LogNet: Warning: UNetDriver::ProcessRemoteFunction: No owning connection for actor

I was wondering if there is an updated way to implement the roles?

This is a reasonably common issue so I have made a note in the video “Fixing SimulatedProxy Prediction” at 5:41. Let me know if that helps.

Yes that has answered my question.

Thank you for your patience and assistance!

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms