I already set up networking with the First Person Shooter Template. (The client and server can shoot the projectile and it shows up in both screens.)
However, I want to use a linetrace. So I set it up and when I start the game, the linetrace only shows up in the server screen. I want the linetrace to show up in both the server and client screens. To debug, I added a “Print String” node. When I shot, it said “Server: Hello” Does this explain why the server is only showing the linetrace? I do have the firing event set to Run On Server and everything is checked Replicate. Do I use Multicast? I don’t know.
Well, The things is that, when you use a linetrace in an event as “run on server” the linetrace will give you the correct result/hit, even if you are calling it from the clients, BUT you wont be able to see the debug line … In fewer words, The trace WORKS, but the debug line don’t work. If you really want to see it, you can use multicast… But just remember to put it back to “Run on server” when you are done.
Well thank you but the linetrace has no rotation when viewed from another client.
^ This is a problem I’m having as well.
The cause could be that you do that linetrace from player’s camera location (from CameraManager) into forward direction of that camera.
If you for example have two players A (host/server) and B (client), and you want to use camera’s location/rotation of player A on player’s B side, you won’t be able to as that player has no information about it afaik. Getting it from player controller won’t work (except for server) as remote clients have only their own player controller in the world.
The location should work if you’d use player’s camera component instead. But it won’t work for rotation.
Recently I was coding a spectator camera for FPP (actually i’m still working on it) so I had to workaround this somehow. The solution I’m using so far, is to have a replicated variable with rotation and in player controller’s tick (of each, LOCAL player) I set that rotation on server side. It then gets replicated to other players and you can use it.
This solution is far from being perfect IMO, but that’s the closest thing to work properly for me so far. The issue with this is, that the ‘flow’ of the rotation on remote clients isn’t smooth at all and you have to make it smoother on your own.
For what you need that linetrace on clients sides? For different goals there might be different solutions.