Announcement

Collapse
No announcement yet.

Executing server event not working for client

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

    Executing server event not working for client

    So basically what I currently have is a door that is set to play an animation whenever a player overlaps the boxtrigger and presses an input. I'm trying to replicate this to players that don't have network authority but it doesn't want to execute the "on server" event that fires the Multicast door opening event.

    This is the blueprint for the door parent class:
    Click image for larger version

Name:	c1afd02a04.jpg
Views:	2134
Size:	116.5 KB
ID:	1605737

    And this is the blueprint for the door class itself:
    Click image for larger version

Name:	faf2b6a44b.png
Views:	1810
Size:	352.1 KB
ID:	1605738

    #2
    The actor holding this script needs to be replicated and has to have a valid owner set (use node "set owner"). Otherwise clients can't call server events on the actor.

    Comment


      #3
      Originally posted by NotSoAccurateNo1 View Post
      The actor holding this script needs to be replicated and has to have a valid owner set (use node "set owner"). Otherwise clients can't call server events on the actor.
      Okay that works, but it doesn't work well when there's more than one player in the box trigger. Currently it sets the owner every time a new player overlaps, but is there any way I can set multiple actors as owners and solve that problem ezpz?

      Edit: I tried to do the above and it works to an extent, but it still seems too resource-heavy for a simple door being opened/closed in multiplayer. I've read that the RPC should be in the player bp to begin with, but I'm not sure how this would work with multiple different types of doors each with their own triggerbox. Would I need to check the overlapped assets every time the player presses E, or make it just trigger an action on the player whenever they overlap the box?

      Did I mention I was new to UE4?
      Last edited by ZONKPUNCHㅤ; 04-10-2019, 12:14 AM.

      Comment


        #4
        Oh, my mistake. Level events can be replicated in the Gamemode blueprint. But I am actually unsure how to do this. I have a silly method of interacting with objects in the world that involves a Interface blueprint that the player uses to trigger scripts in an interactible object. That object then shoots another interface function back at the player. The player then jumps through the "run on server' and "multicast" events, then shoots a final interface function back to the object which is now firing on all clients.


        I'll show these working in step by step then I'll post the interface at the end if you needed to reference it.


        First is interfacing to the player. In this case I save off a reference when I first grab an object and then, when I push my interact button, I interface to that player.

        Click image for larger version  Name:	startremotereplication.PNG Views:	1 Size:	87.5 KB ID:	1606168


        The player then jumps through a "run on server" event then a "multicast event" then interfaces back to the object. There are multiple sets of these nodes here because this way I can allow more than one type of replication for the interactible object.

        Click image for larger version  Name:	interactibleobjectusesplayerasreplication.PNG Views:	1 Size:	357.0 KB ID:	1606171


        Finally, the event returns and fires off the appropriate event based on the integer that I send from the start.

        Click image for larger version  Name:	remotelyreplicatedevents.PNG Views:	1 Size:	141.3 KB ID:	1606169

        ---


        The interface has nothing to it. Just a bunch of differently named functions so that I can have more choices for replicating. Whether all I need is a "run on owning client" or a "run on server" to "multicast" and exclude re-firing on the initial client, and whether or not the action should be rpc reliable.

        Click image for larger version

Name:	image_161874.png
Views:	1697
Size:	110.0 KB
ID:	1606170

        Comment


          #5
          Okay, I'm a bit confused so bear with me. Currently in my door parent bp I have a door mesh and a trigger box. I set up an interface to get the player controller from an input actor. Of course the server has network authority so replication and event triggering works fine on that. For the client however, he's unable to trigger the execute on server event despite being assigned as owner to the door he is overlapping. Both the actor and character are set to replicate.

          Click image for larger version  Name:	b9e152f647.png Views:	1 Size:	24.3 KB ID:	1606361

          Edit: I just tried setting the owner via the overlapping actor node of a triggerbox and it works fine for the client. The set owner node doesn't work in the interface event on the door blueprint; code after it still fires.

          The interface is nothing special, just one function with one input.
          Last edited by ZONKPUNCHㅤ; 04-13-2019, 11:40 AM.

          Comment

          Working...
          X