This template doesn’t seem fit for replication.
I don’t have UE5 atm so I took UE4 FPS template and made a basic replicated fire loop. Hopefully you can grasp the various aspect and adapt to your project.
The UE4 template doesn’t have a rifle class, so I put everything in character. It sounds definitely better to have such logic in rifle class, but it shouldn’t make a big difference overall.
So let’s start with input - we start a fire loop locally and tell server to start firing too.
The local fire loop will not spawn any projectiles, it will only play fire effects for the local player so there’s no apparent round-trip delay between click and visually firing.
We enter fire loop on both local client and server (same machine if we are listen server host btw). There’s a bit of logic to prevent entering loop twice etc, we are maintaining fixed minimum interval between shots - so you can spam clicks or hold LMB and it won’t fire faster than minimum interval.
When a shot is due (FireShot called), the server spawns projectile. If we are the local client (who just clicked), only simulate fire effects for now.
Next we spawn projectile (on server). This is a slightly modified version of the FPS template function that was provided. Do not use FirstPersonCamera as it won’t work on servers for non-host players. Use GetActorEyesViewPoint instead. I’m not familiar with MotionControllers so I left the stuff as-is (might not work).
Also we pass ourselves as instigator/owner of the projectile.
Enable replication on projectile. Use projectile replication to tell all other clients to play fire effects for the player who just fired.
Finally, play fire effects (sound, anims, muzzle flash…)
Note that there are many ways to implement a replicated fire loop. Here I’m spawning the projectile on server, and let the server replicate projectile to clients. And I’m using projectile replication as a “multicast” so I don’t have to use any multicast event.
An alternative would be to not replicate the projectile, and instead use a multicast event, and let everyone spawn his own local projectile.
If the fire loop is very fast, it would be more adapted to replicate only startfire/stopfire all the way to remote clients, and let everyone manage their own fire loop. This way you save bandwidth by not replicating every single shot.
Again it all depends on what your project needs, there’s no one-fits-all solution, which is also why it’s not easy to find full blown multiplayer templates.