One Camera For Players - PUN 2D Game

Hello. I am working on a multiplayer game in unity using Photon (2D game). What I was using before to make the camera move with the player, is that I made the camera , a child of the player , so that the player gets instantiated with its own camera and the camera follows the player.
Now the problem is, as it is a 2D game (platformer like), I want the camera to follow the player with smooth movement (.ie I want to use Lerp). So I made the camera not a child of the player and only camera is available in the scene.What I want is to get the transform of the player that I am controlling and set it to the camera's transform. Like wise , in other's game , the camera should get the transform of that particular player , that they are controlling.

What I am using in my camera script is:
  void Update () {
        		if (GameObject.FindGameObjectWithTag ("Player").GetComponent().isMine) {
        			//I want to get the transform of that particular player.
        		}
        	}
Or is there any other way to achieve this??
Please Help!!

Answers

  • Use the photonview of the player and then instantiate the camera locally, something like this:

    if(photonview.ismine) { instantiate(camera); }

    this code is not right written, but it can help you with what you want.
Sign In or Register to comment.