Shooting direction in dedicated server if camera is nullptr

Hello,

The way my current setup works is player press shoot and I send notification to server, then server uses the camera of player to get position and rotation and do a line trace (and apply bullet spray in future) and return the location bullet should be fired to. Then clients spawn the projectile based on the location bullet should be fired at.

This worked great if server is not dedicated, but on dedicated server there is no camera so i cannot calculate the location to be fired at.

How do you normally do this? I dont want to send fire at location from client, since it can be unreliable. But is that the only way to do this?

Sorry for answering my own question, I keep thinking about solutions but the moment I post question here, something clicks in my mind and solution comes up.

I created a scene component and attached it to camera and set its replication to true. Now instead of getting camera, I just use that scene component to get camera location and rotation and the do the line trace with that data.

edit: I’m still interested to hear how others solved this problem.