line trace replication on client

Hello everyone, i try to create a multiplayer top-down shooter and for that, i would like to replicate the Line Trace of the firing weapon.

When i try on Listen Server, everything is OK (both when server is firing and clients).

When i try on the net mode “play as client” , everything is still replicated but i have a second Line Trace with another trajectory due to the idle mouvment of my character (so potentially one hits and the other not).
Even tried with 1 or 3 clients. Even with the “M_Fire” event on the BP_Weapons set as multicast. There are always 2 lines.

The BPs :


And what is shows ingame :

If you have any idea of what i’m doing wrong, it would be very helpful cause i try for dozen of hours at least and its really frustrating :face_with_diagonal_mouth:

Hey @Kiame

Generally, shot calculations should be done by the server for the actual shot. When you do it on client it’s more for things like VFX and prediction that will be corrected by the server when it does it’s calculations.

If by “idle movement” you mean the animation, that will never work as each machine will be on a different part of the animation loop, so the approach should be to line trace from a steady point not affected by animation.

You can keep the weapon’s muzzle location for VFX, which would be done on clients (Multicast), and trace from the steady point on the Server to calculate the shot, which I assume would be forward from the center maybe with a spread offset on the End point.

Hello, yeah i see what you mean now haha thank you a lot.

For the ones with the same issue :

Have to separate the Line Trace (which Run on Server) and the VFX (which is Multicast)

  • in “Play as Listen Server”, the Line trace is only replicated for the server
  • in “Play as Client”, the Line trace is replicated for each client
    So in my case i want to create a multiplayer game without a player hosting, so that’s good.