Download

Question about Role Authority

I’m truly confused with UT4’s network authority role. Hope someone can help clarify this for me…

On my server, an actor has ROLE_Authority and on the client’s machine, it has ROLE_AutonomousProxy. (Which I hope is right.)
However, the client need to be able to move it around, but it seems that server refuse to listen to him because he has no authority.

Am I doing something wrong here? Should I downgrade the actor’s role on the server to SimulatedProxy or not? How else would I get the client to have authority over some aspect of the actor?

ps. Yes, I have looked over Shooter example for a gazillion times by now. grunt rofl

When you want to perform an action on an actor as a client of which you have no authority over, we simply tell the server to do it for us.
For example, say you want to re-implement jumping, what we do with our game is something akin:



void AMyChar::Jump()
{
    if (CanJump())
    {
        if (Role < ROLE_Authority)
            ServerJump();
    
        DoJump();
    }
}


where ServerJump_Implementation() is the server side implementation of jumping. In our case, because the client side and server side logic were the same, ServerJump_Implementation() would simply invoke AMyChar::Jump() as well, but ofcourse this time the if statement would not execute the ServerJump() branch, since it has authority.

PS: ACharacter’s UCharacterMovementComponent is already replicated. If you move your character using AddMovementInput or whatever the function’s called, it will automatically be handled by the server already.

Strange, I use addmovement and the actor refuse to do anything when it’s a client-owned actor. Do I have to call this on the server side?

Ps. When I call possess(), will it be automatically replicated? If so, where should I call it, server or the client?

Since you are talking about possessing, how do you spawn the actor? You have to make sure that the actor itself gets replicated by the server. There’s a few properties you have to set to true, of which one is bReplicates iirc. Maybe somebody else can tell you more about this.

I use rpc to create a pawn on a server with replicate option checked. The pawn is created on all clients fine.
But then I have no clue how to make one client properly possess the newly created pawn and move it around via c++.

update

I called setOwner() then possess() via NetMulticast and it’s working fine now. Clients can use addMovement to move pawn around.
I still have no clue if this is right though… just a pointer to anyone who’s having the same problem.

Big thx for your help, Shammah. :slight_smile: