Announcement

Collapse
No announcement yet.

Replication trouble

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

  • replied
    Originally posted by Mat5i6 View Post

    Oh ok this is new for me, and you were right. Since the weapon is placed in scene there is no owner being set on it. And of course output log shown it but I was so accustomed to string printing in the viewport that I've absolutely forgot about log tab existence. What a moron I am But this also raises a new question if I may, if I have let's say, a lot of actors that have some network relevance like doors, deposit boxes (opening animation from timelines), etc. what owner should I set it on?

    And of course thank you all very much for finding time to help me.
    Sorry, I had assumed when you'd "picked up" the weapon that you'd done so using an RPC to attach the weapon to your character on the server (this automatically transfers ownership to you, thus enabling the functionality Garner has excellently described).

    With something like a door you don't need to own it to manipulate it, what Garner has been explaining is that you need ownership to invoke a Run On Server event, as without ownership (of the class you're calling an RPC from) the event will fail to get to the server in every case.

    So to clarify, ownership is only required to get you onto the server. Once you're on the server you can manipulate things as the server in most any way you wish and replicate the changes the server makes to clients through one of either: Replicated variables, Run On Owning Client Events (RPC), Multicast (RPC) and/or RepNotify Variables (these are the ones that are important when you're consider Net Relevancy, more detail at the end of this post).

    All you need is a reference to the door/box etc. and the ability to get your input event (open box/door) from your client to the server. Since likely you'll be using your player character class to do this action/input you need to get it to the server using your normal method. Since you already own your character by default the RPC event to "open door/box" will go to the server as expected without issue.

    To ensure you always get the result you want, call your Run On Server event in the class that you own, you can cast/interface to call events on other actors/classes from there with confidence as you definitively have Authority over that thing as the server if you follow this procedure.

    So when you're on the server in your Character Class, you can use your reference variable to cast (or use an interface) to start your timeline that will run in the door/box class. (You can think of it kind of like the server owning the door, and you're asking the server to open the door for you, and since the server has authority over the door, it will oblige. But for accuracy's sake, the server, under the technical UE4 Definition, is not able to have "Ownership" of something, it's more that the server maintains control over anything and everything even when an object is unowned. If you queried "Get Owner" on an object that had no owner, it would return null.

    With regard to relevancy, this isn't related to ownership. Relevancy will determine what a player who wasn't within the net relevant range at the time of the event will see. In this case, if the client is too far away to be net relevant when you opened the door with an event, even if it was multicast (these are fire and forget events in so far as they will only change variables for clients who are net relevant at the time a multicast event is fired), the changes won't be reflected for that client when he becomes relevant without a RepNotify that sets the new state of the door for it, and thus now is out of sync. (i.e. the player who became net relevant will still see the door as closed, while the server and any player that was net relevant at the time would see it as open).
    Net Relevancy quite a broad subject and too detailed to start writing it all out.

    I suggest you go and watch this excellent Epic Tutorial carefully, as it explains everything you need to know in regards to Net Relevancy.

    Here

    Hope this helps.
    Last edited by GrumpyNZ; 11-01-2018, 01:43 PM.

    Leave a comment:


  • replied
    You're welcome.

    A lot of things don't need an owner at all you just have to accept the limitation that you will not be able to use "RunOnServer" RPC's on these actors.
    If you have a treasure chest placed in the world the chest would not be owned by anyone, but how would a client then interact with the chest?
    You would use something that the client already owns like the Pawn/Character and on this make a "RunOnServer" interact event. then the server-side character sends a regular event (non-RPC) to the chest and the chest can set a replicated variable and/or make a Multicast event back to all clients.

    Leave a comment:


  • replied
    Originally posted by GarnerP57 View Post
    Ownership is what makes "RunOnServer" possible so if the client that calls "RunOnServer" is not the owner of the actor when calling the event the server will drop the event and do nothing (there should be a warning in the log showing that the event was dropped).

    So make sure that when the client picks up the weapon that the server "SetOwner" on the weapon to the pawn that the client currently possesses.
    Oh ok this is new for me, and you were right. Since the weapon is placed in scene there is no owner being set on it. And of course output log shown it but I was so accustomed to string printing in the viewport that I've absolutely forgot about log tab existence. What a moron I am But this also raises a new question if I may, if I have let's say, a lot of actors that have some network relevance like doors, deposit boxes (opening animation from timelines), etc. what owner should I set it on?

    And of course thank you all very much for finding time to help me.
    Last edited by Mat5i6; 10-30-2018, 06:26 AM.

    Leave a comment:


  • replied
    As a side-note "SwitchHasAuthority" is redundant in a "RunOnServer" event. It will always be Authority and never remote because the event can't be executed remotely.

    Leave a comment:


  • replied
    Originally posted by Mat5i6 View Post
    ... That's all. I don't have problem with line trace handling or ownership (I'm not even changing it anywhere).
    ...
    Ownership is what makes "RunOnServer" possible so if the client that calls "RunOnServer" is not the owner of the actor when calling the event the server will drop the event and do nothing (there should be a warning in the log showing that the event was dropped).

    So make sure that when the client picks up the weapon that the server "SetOwner" on the weapon to the pawn that the client currently possesses.

    Leave a comment:


  • replied
    Ok, if you want me to take a closer look at the BP you could post the screenshots or something and I could reproduce it. Let me know.

    Leave a comment:


  • replied
    Exactly, I have just a little more clutter in BP but still, it's pretty much the same and that's what bothers me. Normally my/this setup should work but this is some weird kind of exception. As I've wrote the actor is replicated and always relevant to prevent any issue such as this. Otherwise not even listen server would work which currently does. Also yeah sorry about that that's just my bad grammar, I should have put there ; or something, to separate the line trace and the rest to prevent this confusion. Never the less thanks. I will probably redone this network communication in my weapons system there is obviously some weird problem maybe with clean actor I'll get lucky.

    Leave a comment:


  • replied
    Originally posted by Mat5i6 View Post
    ... and from that the line trace and effects such as muzzle flash etc should multicast to all clients.
    But don't look for anything complicated in my example take it just like an actor that should do something on server and after that on every client.
    Just a note, the line trace shouldn't be multicast.

    Leave a comment:


  • replied
    Doing exactly the same method you've done above everything works as expected with the printscreen nodes. Have you double checked that the blueprint is replicated?

    Either that or the reference isn't valid (or not replicated).

    In the below example (on a dedicated server PIE, (but will work fine for listen server too), after having picked up a "Weapon" from the ground and attaching it the "PullTrigger" event is called from the Character's BP and run on the "Weapon" BP. If i understand correctly, this is what you're trying to achieve?

    The only failure scenario's I could quickly find is turning off replication on either the weapon, the character, or both. OR no having a valid Weapon BP reference (replicate your reference variable too).

    (Sorryabt the green on green, was just a template map frm mrktplce)
    Attached Files
    Last edited by GrumpyNZ; 10-29-2018, 04:43 PM.

    Leave a comment:


  • replied
    I have been working on a game and accidentally struck a stray key. Now, I cannot move my third person character with the usual key commands unless I hit the "Possess" button. After I quit I get an error message. "Blueprint Runtime Error:Accessed None trying to read property Animinstance from function:'ExecuteUbergraph_ThirdPersonCharacter' from node: (Symbol here like a tilted Q)Branceh in graph: (symbol again)EventGraph in object" (symbol) ThirdPersonCharacter with description: Accessed None trying to read property Animinstance. Does anybody know what this means and how I can get the game back to normal?

    Leave a comment:


  • replied
    Custom class inheriting from the actor.

    Leave a comment:


  • replied
    What class(es) are you using to run this in?

    If it is in the PlayerController then there's your problem right there, multicast functions won't work in a PlayerController as they only exist on the Server and Owning client.
    Last edited by GrumpyNZ; 10-29-2018, 08:50 AM.

    Leave a comment:


  • replied
    First and foremost thank you all for finding time to reply, unfortunately I've probably gave too much unimportant informations. I really need to figure out just why custom event with marked run on server is unable to be called by any other client than listen server. That's all. I don't have problem with line trace handling or ownership (I'm not even changing it anywhere).

    I'm now posting here only the relevant part, here is a few events that gets called locally after clicking left mouse button.

    Click image for larger version

Name:	local.png
Views:	387
Size:	57.8 KB
ID:	1545095

    Here is where it gets wrong. HandleFireServer is called only from listen server. Client 1 and any other is unable to call it so every other event after that isn't called and print string "handleFireServer" isn't printed.

    Click image for larger version

Name:	server.png
Views:	387
Size:	88.1 KB
ID:	1545096

    I hope this time I wrote everything important.

    Leave a comment:


  • replied
    That weapon if placed in the world is owned by nothing. When it is picked up the server has to SetOwner to something that the client already owns so the client becomes owner of the weapon.

    Ownership is inherited so could be like this "PlayerController<-Character<-Weapon". This means that if you SetOwner on the Weapon to be the Character that the client owns the client now eventually owns that weapon too.

    Note that if a Client try to SetOwner nothing happens. It is ONLY the server that can change Ownership.

    Be careful not to confuse Authority with Ownership.
    Authority is given to whoever spawned the Actor and is never changed. If a client spawns an Actor it will never be able to use any network abilities like sending RPC's or replicating variables.
    Ownership can be changed by the server at any time.
    Last edited by GarnerP57; 10-27-2018, 11:49 AM.

    Leave a comment:


  • replied
    Are you sure you understand replication? Clients don't have authority over anything but themselves, they don't have authority over the servers copy or any other copy. There's a lot of dicey information out there (especially on Youtube) that teaches incorrect techniques. Start with this tutorial series by Epic here.

    The server will always be able to do everything as it should when it's a listen server, in this scenario it has authority over all replicated instances of its character and thus encounters no issues and doesn't require any RPC's to get things to work, the trick is to get things to work on clients.

    I've attached a blueprint that works on listen and dedicated servers for you to study. Hope it helps. It fires a line trace from a "Gun Barrel" (reference your picked up weapon in place of this)

    Also make sure your collisions are set to block whichever sort of line trace you decide to run so you get a hit result. In the below example you need to set the Capsule Component to block visibility. Visibility isn't the best trace to use by any means for a gun but it works for the sake of this example.

    Not the below example runs in a Character Blueprint.
    Attached Files
    Last edited by GrumpyNZ; 10-27-2018, 12:27 PM.

    Leave a comment:

Working...
X