How to make camera to follow player in 2d multiplayer game?

I want to make camera to follow player in x and y direction.I have gone through lot of tutorials but none of them is working for multiplayer. How can I make camera to follow to player in multiplayer 2d game.

Maybe this script will help you.

Add the script to the camera, set your character as the target and choose which type of follow you want to use.

Use the same code as you would for single player, but bracket it in an if statement:

// Code here to move camera

I’m assuming you already have the namespace:

using UnityEngine.Neworking;

and the PlayerPrefab’s Network Identity component has “Local Player Authority” checked.

That should have each player’s camera follow their own player.