Announcement

Collapse
No announcement yet.

Clients are Considered ROLE_Authority?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Clients are Considered ROLE_Authority?

    I was trying to do some simple networking on a little game I'm working on. I noticed some things weren't really working out when they should be. After hours of troubleshooting, I decided to just run the game as a dedicated server, and in my player class, in the BeginPlay method, included an if statement that checks if Role == ROLE_Authority. If true, it would just UE_LOG something to let me know it was activated. When I activated it, the log was printed, even though there was only one person, and it was a Client. Running this on a non-dedicated server with two players printed the text twice, once for the Server, and the other for the Client again.

    I thought I had a slight grasp onto these concepts of Authority, but this seemed to be completely opposite of what I thought. Do Clients have ROLE_Authority, or am I implementing my code incorrectly?

    Thank you.

    #2
    Perhaps you looked at RemoteRole? This would show the opposite of Role.

    Actors spawned by a client can have ROLE_Authority, but only Actors spawned by the Server can replicate.

    Comment


      #3
      Actors spawned by the client itself have Role == ROLE_Authority on the client (since the actor only exists on the client, the client is also authoritative over it). So are you making sure the actor you're spawning is spawned by the server, and only by the server? From your logging it sounds like the client is spawning the actor. If you're triggering this from input, make sure you are calling a server RPC that then spawns the replicated actor.
      Journeyman's Minimap - Available on Marketplace - Forum topic - Video

      Comment


        #4
        Hmm... So I made it so that only the Server spawns the Actor, and it gave me some funky warning. "UNetDriver::ProcessRemoteFunction: No owning connection for actor". So apparently my Actor doesn't have an owning connection? Even when allowing it to spawn from Client or Server, I still get the warning.

        Comment


          #5
          Clients cannot call RPC's on actors unless they are the "Owner" of that actor. The Owner is a replicated property which should be set by the Server. It can be changed whenever you like (SetOwner()), but the only the current owner is allowed to call RPC's

          Owners are typically pawns or player controllers - but so long as the chain of ownership is headed by a player controller you can call the RPC successfully.

          Comment

          Working...
          X