Hi, I’m currently working on a multiplayer third person shooter game and I was wondering how would I go about getting shooting working.
I have the animation working via a repNotify, but I was wondering how I’d actually have the projectile spawn and deal damage as well as the replication, is it run on the server or client or both? I’ve done offline before but this is my first time doing online and there’s plenty of tutorials on shooting but I haven’t seen anything on adapting it for replication.
Separate the idea of visual vs hit detection. While you want to spawn an actor to represent a projectile, it only represents a visual that can be “close” to synced on client and server. Server has authority, it’s the only one that really matters.
In a simple way of explaining, without code, the big games now-a-days “rewind” a shoot notification; that is, when a shoot notification is received from the server, it calculates backwards everyone’s positions to determine if a project will hit. That is, an instant projectile like a bullet. If it immediately determines a hit, it records it - either way, a visual is signaled to play, but since it already knows if hit or not, it can determine the right visuals to show.
If you do have projectiles that move,then rewind players, then spawn the projectile. It’s most important of tracking its position on the server - the clients can replicate that projectile, but only track on the server the hit detection and signal to the clients what to do.