Photon camera problum
Hello Unity Answer, I am a first year college student going to school to be a game developer. That means I am not as good of a programmer as you guys yet. But me and my friends have decided to make a game of mine, a 2D social MMO. Currently, we are having problems with cameras. I don't know how to do it. What I need is a camera to spawn for each player and be activated for each client. Currently, we are spawning the player and the camera but when another player spawns in, they will start using the first user's camera, which means they are all using the first camera spawned in. I don't want that, I want each user to have their own camera, and to have their own camera view. So I went to the Unity Forums to see if anyone could help me with my problem, and one such person did. Would have posted here, but, I see Unity Answer as an area where you only go if you have a broken script or something like that. Since I didn't have a script I didn't feel like I could come here. Now I have broken scripts and I am confused out of my mind. Here is my movement script where I was told to put this piece of code this guy gave me:
using UnityEngine;
using System.Collections;
using ExitGames.Client.Photon;
public class PlayerMovement : Photon.MonoBehaviour
{
public float speed = 1f;
void Start()
{
PhotonNetwork.sendRate = 20;
PhotonNetwork.sendRateOnSerialize = 10;
}
void OnPhotonSerializeView(
PhotonStream stream,
PhotonMessageInfo info)
{
if(stream.isWriting == true)
{
stream.SendNext(speed);
}
else
{
speed = (float)stream.ReceiveNext();
}
}
public GameObject yourObject;
void Awake()
{
if (!photonView.IsMine)
{
yourObject.SetActive(false);
}
}
void Update()
{
MovePlayer();
}
void MovePlayer()
{
if (!photonView.isMine)
{
return;
}
{
if (Input.GetKey(KeyCode.D))
transform.position += new Vector3(speed * Time.deltaTime, 0.0f, 0.0f);
if (Input.GetKey(KeyCode.A))
transform.position -= new Vector3(speed * Time.deltaTime, 0.0f, 0.0f);
if (Input.GetKey(KeyCode.W))
transform.position += new Vector3(0.0f, speed * Time.deltaTime, 0.0f);
if (Input.GetKey(KeyCode.S))
transform.position -= new Vector3(0.0f, speed * Time.deltaTime, 0.0f);
}
}
}
hare is the piece of code this guy gave me
void Awake()
{
if (!photonView.IsMine)
{
yourObject.SetActive(false);
}
}
Now the only thing my movement script does is disable itself once a player spawns in. I'm 190% sure I'm being an idiot here, so I'm coming to you guys to see what I'm doing wrong, and to get a camera for each player. PS, we are using Photon Framework.