Announcement

Collapse
No announcement yet.

Replicating an item and destroying it isn't working under multicast event

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

    Replicating an item and destroying it isn't working under multicast event

    Hi, I have a pickup class and when a player walks over this class and presses the pickup key, it will spawn an emitter and after a delay it will remove the actor and the emitter.

    This issue I am having is it is getting destroyed on the server but not the client. If I pickup the item on the client, the event never gets executed (it just prints "Client"). When I run this on the server, the emitter spawns and the emitter gets destroyed on the server, but the actor stays on the client with the emitter.

    I have 2 events, one for the server which uses "multicast" and one for the client which replicated using "Run on server". Anyone know why this is happening?Click image for larger version

Name:	Screenshot_1.png
Views:	124
Size:	454.0 KB
ID:	1481433

    #2
    The first thing I would try is replicating your "Can Pick Up" boolean. Click boolean and in upper right menu of options is the option to Replicate. The second thing I would try is removing the Switch Has Authority and go right into the Spawn Emitter. Try both Multicast and Run On Server. Server/Client programming is pretty annoying. I've spent a decent amount of time on it and I still find myself sometimes just playing with combinations until the thing works.

    Comment


      #3
      Also when replicating in general you usually want the replicated events to be as simple as possible. So you might want "Spawn Emitter" to plug into "Spawn Emitter at Location" and nothing else. Put that other programming on the input action perhaps.

      Comment


        #4
        Originally posted by Allenheathx View Post
        Also when replicating in general you usually want the replicated events to be as simple as possible. So you might want "Spawn Emitter" to plug into "Spawn Emitter at Location" and nothing else. Put that other programming on the input action perhaps.
        I have the switch has authority because I need to know if it is the server running this or a client. I think the issue is with the Client Spawn Emitter and where it says (if owning client) because the client doesn't not own this actor. I am not sure how to fix this though.

        Comment


          #5
          did you try replicating your "Can Pick Up" boolean. You definitely want to try that if you haven't.

          Comment


            #6
            Originally posted by Allenheathx View Post
            did you try replicating your "Can Pick Up" boolean. You definitely want to try that if you haven't.
            Yeah I did, I added that just as a server side check but even if I remove HasAuthority and try to execute Client Spawn Emitter, it won't contact the server to run this function. It must be because it says (If owning client) but I don't know how to get around this or force this to execute on the server.

            Comment


              #7
              I don't know what blueprint you are calling this from but if it is the actor you should be able to Run On Server and then run one without any replication and it should work.
              Last edited by Allenheathx; 05-27-2018, 08:33 PM.

              Comment


                #8
                Originally posted by Allenheathx View Post
                I don't know what blueprint you are calling this from but if it is the actor you should be able to Run On Server and then run one without any replication and it should work.
                This blueprint is being spawned in from the server onto the map. (spawned in from the level blueprint). I could after the branch, just destroy the actor and it would work but I need the server to do this so that later on I can store the item in the database or do some other server side things.

                Comment


                  #9
                  Originally posted by Ericode View Post

                  I have the switch has authority because I need to know if it is the server running this or a client. I think the issue is with the Client Spawn Emitter and where it says (if owning client) because the client doesn't not own this actor. I am not sure how to fix this though.

                  Your assumption is correct. The "InputAction Pickup" event can never be called on a client unless if the client owns the actor.

                  It doesn't make sense to change the ownership before it is picked up so your only option is to tell the server elsewhere to do the picking up on the client.

                  A way could be to have the "InputAction Pickup" on your Pawn/Character. When this event is called here it calls a "Run On Server" event that do the destroying of the actor and Multicasts any necessary updates back to the clients(destroying a replicated actor on the server automatically updates on the client).

                  Comment

                  Working...
                  X