Announcement

Collapse
No announcement yet.

Replication trouble

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

  • replied
    Yeah sorry forgot to mention that I don't plan to use dedicated server in any way so it's client 1 with authority.
    Also I do understand the way how replication should work I've managed to make work multiple of them before it's just this one I cannot figure out. So call stack would look like:
    By pressing fire key blueprint interface sends command to the weapon to fire, fire event executes camera shake etc. and at the end calls custom event which should be run on the server (this is where the problem is, it never get's fired) 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.

    Leave a comment:


  • replied
    I need a little more information about your setup. Are you running the server as a listen server (Client 1 is effectively the server with "authority" and Clients 2+ are connecting to Client 1) or a dedicated server (Server is launched separately from the clients, Clients 1+ are all "remote")?

    I'm guessing your weapon is set to "replicated", so all clients see that the weapon is picked up.

    When you fire the weapon, you need to make an RPC call to basically say "I fired my weapon / I pressed the left mouse button!". So you'd need to call an event that executes on the server. Note that you should keep in mind what elements live on the client and what elements exist on the server (or both). I like referring to this document (http://cedric-neukirchen.net/Downloa...Neukirchen.pdf) on page 8, there's a good chart to show what lives where. So, for example, if you tried to run an event on the server within a UMG widget, it wouldn't work at all because the server code does not execute for UMG widgets.

    Lets say you are running the code on your character. You have a Left Click event and you have it call another event, "S_WeaponFire" or whatever. S_WeaponFire needs to be set to "Run On server". Now the server knows the weapon is firing. If you want, here you can perform checks to ensure the player has enough ammo or that the weapon is valid, etc. If everything checks out OK, call another event, "MC_WeaponFire" or whatever. MC_WeaponFire is basically just a way to broadcast that the weapon fired to all other players. Set it to Multicast and reliable. Here, you would perform your visual effects like muzzle flash.

    Now you have the basic framework for setting this up. Ideally, you want to perform all your calculations on the server, so within the "S_WeaponFire". If you want to perform a line trace and determine what actors are hit, do it on the server. Effectively, you don't want the clients deciding if they were hit or if they hit another player - the server should make that call.

    Leave a comment:


  • started a topic Replication trouble

    Replication trouble

    Hi there! For a week now I have this interesting problem with which I cannot really wrap my head around it. I'm trying to replicate a few events from owning client to all clients. Unfortunately for some reason my general approach (run on server if owning client -> has authority -> multicast) isn't working and not even the run on server get's called even though the actor is replicated and always relevant.

    To be more specific, I have a weapon placed in the scene that can be picked up so far so good but when I try to fire it, client is unable to call server events eg. spawn muzzle effect, run line trace, etc. Unlike server which can do everything as it should.

    Any suggestion would be greatly appreciated, thanks in advance,
    Mat5i6.
Working...
X