Announcement

Collapse
No announcement yet.

How to *NOT* replicate to calling/owning client?

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

    How to *NOT* replicate to calling/owning client?

    Background: In my project I don't care too much for being that accurate about players bullets or hit detection, in fact its important to game-play that its mainly done client side. However it does need replicating for other clients to see the bullets and effects.

    My Issue: I spawn bullets client side then tell the server to do the same, so all clients get the bullets too. The issue is that when the server spawns the bullets, it also spawns them a *second* time on the client that requested the server do so. This means the owning/calling client gets two sets of bullets.

    So I want to know, is there a way to call a server custom event and have it only do thing for the *other* clients? Or a way to set actor replication to not replicate to the caller/owner?

    #2
    how about just do a multicast event and NOT spawn the bullet manually on owning client?
    This would just solve your problem exactly how you'd like it right?
    Unreal Engine 4 Game Framework diagram for relation of all major base object types
    Unreal Engine 4 Input Event diagram, scroll down to section Input Processing Procedural
    Resident Evil Classic Camera
    RPCs official document, Must Read
    Everything you should know about replication

    Comment


      #3
      That is exactly what I need to do. I've been looking at doing exactly that, but posted this question as I can't actually see a way to say "This multicast (or server) request originated from this client, so don't run" - there is no "caller" or "owner" attached to the request or any other context I can see, which is a little surprising. Did you can a specific idea in mind?

      Comment


        #4
        I know what you are saying but bullet is not a good example, as you really don't need to spawn first and call a multicast, won't save you much time or bandwidth.

        so, let's say in case you actually needs to do this(multi cast but not on event issuing client), there are a few things you can do:
        1. pass player name(I think you can get it from controller or playerstate) to the event, so when the event fires on all client, compare, only run when player name is different from your own.
        2. like above use anything that is unique, ie, name of player controller is unique on all clients including server. say if your current client controller is PC_5, on server it might be PC_2, and on another client it's PC_14.
        3. set a non-replicated variable boolean to true before you fire event, check for it when event gets called, if it's owning client, branch and do nothing but set the boolean back to false, on all other client, do the things you need to do.
        (have to be very careful about this approach, as this might cause a race condition as events could probably fired not in order, ie client A fires event and shortly clientB also fires event, assume A's event arrives after B fires event, client A's event will not run on both A and B, while client B's event runs on both A and B)



        but again, if it's for bullet, save your trouble and just use multicast.
        Last edited by PenguinTD; 08-27-2014, 12:54 AM. Reason: add caution explanation to option 3
        Unreal Engine 4 Game Framework diagram for relation of all major base object types
        Unreal Engine 4 Input Event diagram, scroll down to section Input Processing Procedural
        Resident Evil Classic Camera
        RPCs official document, Must Read
        Everything you should know about replication

        Comment


          #5
          I agree bullets are not the ideal use here, however I'm experimenting with a rather twitch based Co-Op game, where the nature of the game means its ok for projectiles to be a little out of sync. The player is going to *really* want to have instant fire reaction so waiting for server response isn't going to work nicely. Replicating the bullets is super easy if I simply let the server spawn them, they go to all clients and all is nice apart from the duplicating. Using multicast would technically solve the issue, but I'd have to manually manage all the rotations, velocity, etc, which kind of defeats the purpose of using UE4.

          I guess I'll experiment some more, though I may put my project aside for a while, as I'm finding too many bugs or missing docs or missing functions in blueprint.

          Comment


            #6
            Originally posted by Durandle View Post
            I agree bullets are not the ideal use here, however I'm experimenting with a rather twitch based Co-Op game, where the nature of the game means its ok for projectiles to be a little out of sync. The player is going to *really* want to have instant fire reaction so waiting for server response isn't going to work nicely. Replicating the bullets is super easy if I simply let the server spawn them, they go to all clients and all is nice apart from the duplicating. Using multicast would technically solve the issue, but I'd have to manually manage all the rotations, velocity, etc, which kind of defeats the purpose of using UE4.

            I guess I'll experiment some more, though I may put my project aside for a while, as I'm finding too many bugs or missing docs or missing functions in blueprint.
            Hi there, did you ever manage to get this done, been trying to do it too, I use a stupid method of deleting the one on the server for the client, any better method for filtering the spawn actor from class?
            Like a replication condition for it, so that it would skip the owner even in C++ would help a lot, thanks!

            Comment

            Working...
            X