Announcement

Collapse
No announcement yet.

Replication problem

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

  • replied
    Originally posted by eXi View Post
    I know it's frustrating if it doesn't work. That's why we recommend beginners to first learn the Engine in SinglePlayer Games before moving to Networking.
    It's a whole new level and the learning curve is pretty high.

    Try to fiddle around with the basic replication. Watch Epic Networking Videos on Youtube and check out Games like BallBump in my Free Project or
    the Multiplayer Shootout of Epic.
    I'm downloading sample projects,

    And I know engine basics,bp,animation etc.

    But,multiplayer is different.It affects all of them.

    Thanks for your helps.

    Leave a comment:


  • replied
    Originally posted by SoloWarrior View Post
    I can understand you,

    I watched some videos and I'm doing same bp.

    But it isn't working,I will download a tutorial project about it.
    I know it's frustrating if it doesn't work. That's why we recommend beginners to first learn the Engine in SinglePlayer Games before moving to Networking.
    It's a whole new level and the learning curve is pretty high.

    Try to fiddle around with the basic replication. Watch Epic Networking Videos on Youtube and check out Games like BallBump in my Free Project or
    the Multiplayer Shootout of Epic.

    Leave a comment:


  • replied
    Originally posted by eXi View Post
    Sorry but there a A LOT of basic networking example out there (for example in my signature) and Epic made training videos about this.
    The basic networking and replication part is documented enough to understand it.

    As long as you guys don't post pictures and information about your attempts, i can only say that you're doing something wrong.

    You need to make sure that the actor you're trying to call RPCs on is set to "Replicate" and is actually owned by the Client (so the PlayerController of the Client is set as the owner).
    A possessed PlayerCharacter is owned by the Client, but you need to make sure that in the ClassDefaults, "Replicates" is set to true. If the Actor is not owned by the Client (for example
    spawned by the Server without setting the correct owner or just placing the Actor in the scene), then the "Client to Server" call will be dropped and never reach the Server.

    Then you need a replicated Variable. This can only be set by the Server. So the way @LazyLoading posted is correct.

    It doesn't have to be "RepNotify" if you don't want to do stuff when the Replication is done.
    "RepNotify" is only needed if you need a function that is called on the Client once the Replication is done.
    These are the "OnRep_" functions you see in the function list of @LazyLoadings pictures. They are created
    automatically once you set a variable to "RepNotify". But you might only need the normal "Replicate".

    If you print the Variable too fast it might still be the old value. Replication takes a really short time, but it's enough time to actually see old values of you are too fast.
    When the Numbers don't change at all, make sure that the P and O buttons are actually called (PrintString or Breakpoints) and then that the ServerPKey and ServerOKey
    are called (again, PrintString or Breakpoints).
    I can understand you,

    I watched some videos and I'm doing same bp.

    But it isn't working,I will download a tutorial project about it.

    Leave a comment:


  • replied
    Sorry but there a A LOT of basic networking example out there (for example in my signature) and Epic made training videos about this.
    The basic networking and replication part is documented enough to understand it.

    As long as you guys don't post pictures and information about your attempts, i can only say that you're doing something wrong.

    You need to make sure that the actor you're trying to call RPCs on is set to "Replicate" and is actually owned by the Client (so the PlayerController of the Client is set as the owner).
    A possessed PlayerCharacter is owned by the Client, but you need to make sure that in the ClassDefaults, "Replicates" is set to true. If the Actor is not owned by the Client (for example
    spawned by the Server without setting the correct owner or just placing the Actor in the scene), then the "Client to Server" call will be dropped and never reach the Server.

    Then you need a replicated Variable. This can only be set by the Server. So the way @LazyLoading posted is correct.

    It doesn't have to be "RepNotify" if you don't want to do stuff when the Replication is done.
    "RepNotify" is only needed if you need a function that is called on the Client once the Replication is done.
    These are the "OnRep_" functions you see in the function list of @LazyLoadings pictures. They are created
    automatically once you set a variable to "RepNotify". But you might only need the normal "Replicate".

    If you print the Variable too fast it might still be the old value. Replication takes a really short time, but it's enough time to actually see old values of you are too fast.
    When the Numbers don't change at all, make sure that the P and O buttons are actually called (PrintString or Breakpoints) and then that the ServerPKey and ServerOKey
    are called (again, PrintString or Breakpoints).

    Leave a comment:


  • replied
    Originally posted by SoloWarrior View Post
    I tried it,and it isn't working.

    Can it will be a engine problem?

    Because,I'm doing same bp and it isn't working.
    Same here, it kind of works but my variable updates a value which is bound to some text on a UMG, when I increment from the server both client and server values change, if I increment from the client the UMG doesn't update on the server. Going back to increment from server will reset the variable to the servers value for the client?
    I'm replicating the variable on an actor which is replicated, documentation could be better.

    Leave a comment:


  • replied
    Originally posted by LazyLoading View Post
    If you look at the example I posted, the p key sends a variable from the client to the server.
    I tried it,and it isn't working.

    Can it will be a engine problem?

    Because,I'm doing same bp and it isn't working.

    Leave a comment:


  • replied
    If you look at the example I posted, the p key sends a variable from the client to the server.

    Leave a comment:


  • replied
    I have a use case where I need to update a variable from client to server. Both the server and client have an index number that they share but I can only replicate the variable from server to client. I am pretty sure after extensive testing that this behaviour is inherent and I won't be able to update the variable from the client. I am not having much success using a replicated function to update the server however.

    Leave a comment:


  • replied
    It is working.

    The server and the client both have separate Bn values that do not relate to each other.

    If you press O in the client, you updated the client's Bn to 2 by telling the server to update the variable.

    If you press Z to print in the client, it says Client 1: 2. If you press Z in the server, it says Server: 1 because the server's own Bn was not updated.

    If you press O in the server, you now updated the server's own Bn to 2.

    If you press Z in the client, it should still say Client 1: 2. If you press Z in the server, it should now say Server: 2 since the server's Bn was just updated.

    This is correct as the Server has its own Bn value.

    Think of the server as another client. It just has special network authority.
    Last edited by ToxinGaming; 02-18-2016, 07:45 PM.

    Leave a comment:


  • replied
    Originally posted by LazyLoading View Post
    I also noticed that R will only be called when R is pressed on the server. You should make a custom event to call. The replication will also not be instant. If you need to do something when a variable is updated you can set it's replication to RepNotify which will call a function when it is updated in the client and server. I made an example real quick here. The red comments are only run on the server.

    [ATTACH=CONFIG]79368[/ATTACH]
    I did it but it isn't works.

    I'm pressing o in client,and printing value,it says value is 3.

    After that,I'm pressing z in server,it says value is 1.

    Is it an engine bug?(or my small brain)
    Attached Files

    Leave a comment:


  • replied
    I also noticed that R will only be called when R is pressed on the server. You should make a custom event to call. The replication will also not be instant. If you need to do something when a variable is updated you can set it's replication to RepNotify which will call a function when it is updated in the client and server. I made an example real quick here. The red comments are only run on the server.

    Click image for larger version

Name:	ZQ54EOr.png
Views:	1
Size:	374.6 KB
ID:	1100807

    Leave a comment:


  • replied
    Originally posted by LazyLoading View Post
    Because you turned off replication on your variable. The function is being called on the server but because it's not replicated, it isn't set on the clients. I would recommend you watch the Unreal Networking Basics tutorial as that really helped me to understand what's happening where. Link.
    Thanks,I'm going to watch it.

    But,

    I tried to replicate it but it didn't work.

    I want to press a button in client and change server's health(example.)

    I will write you after the tutorial.

    Sorry for my English,I'm killing the English

    Leave a comment:


  • replied
    Because you turned off replication on your variable. The function is being called on the server but because it's not replicated, it isn't set on the clients. I would recommend you watch the Unreal Networking Basics tutorial as that really helped me to understand what's happening where. Link.

    Leave a comment:


  • replied
    Also,it didn't work
    Attached Files

    Leave a comment:


  • replied
    Originally posted by LazyLoading View Post
    It doesn't work because replicated variables are only replicated one way, from Server to Client. If you want an event to happen on the server from the client you can make a function and set it's replication to Run on server, anything after that event will be run on the server. In general advice, you should not trust your clients with important game data such as health, etc.
    I can't understand you,

    Did you mean stroge your variables to server?

    How can I do it?

    And,

    Is game finishes when server player leaves the session?(my english dead here )

    Thanks for your help.

    Leave a comment:

Working...
X