Announcement

Collapse
No announcement yet.

Basic replication : Client doesn't replicate to server

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

    Basic replication : Client doesn't replicate to server

    Click image for larger version

Name:	Untitled.png
Views:	118
Size:	464.0 KB
ID:	1700926

    Hi, I am trying to do basic interaction for multiplayer. Each player can cast a ray and upon hitting the floor, it will print a string.

    There is no problem on the server side but my client doesn't print the string. It goes as far as ChangeColor(Server) for the Client side but it does not run the multicast for some reason.

    What have gone wrong here?
    Attached Files

    #2
    Only the owner of Floor_change_sample can make the RunOnServer RPC. If Floor_change_sample is a single Actor placed in the level then it probably doesn't have any owner so RunOnServer RPC's will fail except on the server because it will run that function as a regular function.

    You need to make the RunOnServer RPC on an Actor that the Client already owns like the PlayerController or Pawn/Character.

    Make a RunOnServer "Use" event on the PlayerController and everything on the Floor_change_sample can be handled on the Server from there.
    Last edited by GarnerP57; 12-22-2019, 09:04 AM.

    Comment


      #3
      Originally posted by GarnerP57 View Post
      Only the owner of Floor_change_sample can make the RunOnServer RPC. If Floor_change_sample is a single Actor placed in the level then it probably doesn't have any owner so RunOnServer RPC's will fail except on the server because it will run that function as a regular function.

      You need to make the RunOnServer RPC on an Actor that the Client already owns like the PlayerController or Pawn/Character.

      Make a RunOnServer "Use" event on the PlayerController and everything on the Floor_change_sample can be handled on the Server from there.
      Hi thanks for the reply.

      I can make it work if I made the replication call on Player Character. My question however, what if I need to call replication outside player characters or object w/o owners. Is there a way around it?

      Thank you for your time

      Comment


        #4
        No it is a how server authority works for security and performance reasons. Only owning connections are privileged to communicate with the server.

        If you don't want to fill up your PlayerController or Character with specific input events you could make components dedicated to the task and attach them to the PlayerController or Character so they also become client owned.

        If the Actor doesn't "belong" to the world like a player weapon then if it is owned by eg. the Character it will also be owned by the client.

        Comment


          #5
          Originally posted by GarnerP57 View Post
          No it is a how server authority works for security and performance reasons. Only owning connections are privileged to communicate with the server.

          If you don't want to fill up your PlayerController or Character with specific input events you could make components dedicated to the task and attach them to the PlayerController or Character so they also become client owned.

          If the Actor doesn't "belong" to the world like a player weapon then if it is owned by eg. the Character it will also be owned by the client.
          Thanks, so if i have game mode logic (something that is responsible for spawning AI for example), should I make a bp and attach it to the player character?

          Comment


            #6
            The server can always do what it wants, it doesn't need to be the owner of something. It is Only when a client needs to ask the server to do something that ownership becomes important.

            Spawning AI and GameMode things should just happen on the GameMode or wherever you think is appropiate. Player input (RunOnServer) events is the only thing that should happen on the PlayerController or Character or anything attached to it.

            GameMode only exist on the server so Client don't even know it exists.

            GameState can't be owned by a Client so it is where the server posts events to the Clients never the other way (RunOnServer is impossible)

            PlayerState is similar to GameState but one instance exists per player connected.
            Last edited by GarnerP57; 12-23-2019, 08:18 AM.

            Comment


              #7
              Thank you!

              Comment

              Working...
              X