Multiplayer issues with switching between multiple cameras and line traces


I have a shooting game setup, and I’ve just recently added the ability to switch between First and Third person cameras (2 separate cameras on the main character). I keep track of this with a bool and change my line trace end to reflect which camera is selected at the time. This works great on the server side, the line trace starts and ends exactly where it should on both views, however on the client side only the third person view works.

In my troubleshooting I have tried many camera settings, removing ADS, changing what the camera is attached to and I’m starting to think it’s a bug, or some misunderstanding on my part. The issue is the projectiles are offset from the centre of the screen/camera for the client in FPS mode.

What Works:
-TPS on Server
-FPS on Server
-TPS on Client

What doesn’t:
-FPS on client

Pictures attached.

Maybe it’s not activating your FP Camera component on server because the code is just running locally. I would try copying the activation logic to the Server Event.

Hi Gbr,

Thank you very much for your reply. I just tried moving it to the server side, and the camera did not appear to change on the client when pressing V - I then tried copying it so it’s in the original location as well as on the run on server node as pictured below - but unfortunately the results are the same. Any other ideas?

Print FP Camera Location and Rotation for both server and client, in every Tick, since you use both to calculate your trace, and you can check any discrepancy.

Here you go - Green is code run on client, Yellow is server run event code. I made it so I can toggle on/off the messages so i didn’t see both the server player and client player’s camera positions at the same time. It does look like there is a discrepancy for almost everything - I’m not sure how I would go about correcting/syncing this though - I already tried ticking “Component replicates” for both camera’s on the player without success.

Client Player:

An update on this… using get control rotation only for First Person view I was able to get it to mostly work. There’s a few small issues now:

-On FPS or TPS mode the client, when away from the server will sometimes experience the bullets firing from above or below the gun rather than the muzzle itself
-ADS sometimes ignores the pitch of the client when away from the server

I’m really starting to feel like I hit a bug in the engine.

Ok I think I got it working with passing the client muzzle + active camera location and rotation to the server… may open possibilities to cheat but I can’t find any other way.