I am working on a racing game and I have a problem, when i enters a room and spawn to the ground it works fine but when another player enters he turns his camera into my camera and he can control my vehicle
(CSharp):
void Awake()
{
SpawnPlayer();
}
public void SpawnPlayer()
{
Vector3 p = Vector3.zero;
Quaternion r = Quaternion.identity;
//Get Position and rotation from a spawnPoint
GetSpawnPoint(out p, out r);
SpawnPlayer(p, r);
}
public void SpawnPlayer(Vector3 Position, Quaternion Rotation)
{
if (PlayerPrefab == null)
{
Debug.Log("Player Prefabs I was not assigned yet!");
return;
}
//Sure of have just only player on room
if (m_Player != null)
{
if (m_Player.GetComponent<bl_PlayerCar>().isPlayerInsideVehicle)
{
m_Player.GetComponent<bl_PlayerCar>().ExitVehicle();
}
NetworkDestroy(m_Player);
}
StartCoroutine(CountStart());
Vector3 fp = Position + Vector3.up;
m_Player = PhotonNetwork.Instantiate(PlayerPrefab.name, fp, Rotation, 0);
if (photonView.IsMine)
{
SkyCamera.SetActive(false);
((MonoBehaviour)m_Player.GetComponent("CarController")).enabled = true;
((MonoBehaviour)m_Player.GetComponent("CarUserControl")).enabled = true;
m_Player.transform.Find("VehicleCamera").gameObject.SetActive(true);
}
else
{
SkyCamera.SetActive(false);
((MonoBehaviour)m_Player.GetComponent("CarController")).enabled = true;
((MonoBehaviour)m_Player.GetComponent("CarUserControl")).enabled = true;
m_Player.transform.Find("VehicleCamera").gameObject.SetActive(true);
}