Download

Best approach for camera code from local to network multiplayer

Im doing a single cam game, where if multiple players are in the same game, they all share the same 1 camera.

I have some simple camera code in MyCharacter.cpp.

For single player, it just follows the character around, as normal.

Using the GameMode to get all Players, I was able to do some local multiplayer camera where it finds the “centre” between 2,3 or 4 players, and zooms in/out as they move apart.

When doing this online, it doesnt work and I’m unsure how I should approach this.

Currently MyCharacter has the Camera code, but should this be somewhere else?

If I keep doing what I’m currently doing, GameMode doesnt work for clients, so in their Camera code do I just say : “if not HasAuthority dont do anything”, then replicate the CameraLocation from Server to clients?

For anyone who comes across this, I just looped over AllPlayers and got their Pawn to do my camera calc for each “in level pawn”, in my Character class

GameState>AllPlayers*>GetPawn()

So I’m not using any replicated variables over client/server. Not sure if this is the correct way to do it though ?