Skip to content

Commit

Permalink
FIXED THE COLORS!!!
Browse files Browse the repository at this point in the history
  • Loading branch information
dcmrobin committed Mar 29, 2023
1 parent 0d9053e commit 07d35bd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
11 changes: 10 additions & 1 deletion Assets/Game/Scripts/GameSetupController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using Photon.Realtime;

public class GameSetupController : MonoBehaviour
public class GameSetupController : MonoBehaviourPunCallbacks
{
//public Camera[] cameras;
public Camera[] cameras;
Text usrText;
public Color playerCol;
GameObject player;
//public Camera SceneCam;
// Start is called before the first frame update
void Awake()
Expand All @@ -24,9 +26,16 @@ private void CreatePlayer()
{
Debug.Log("Creating Player");
GameObject myPlayerGo = (GameObject)PhotonNetwork.Instantiate(Path.Combine("PhotonPrefabs", "Player"), Vector3.zero, Quaternion.identity);
player = myPlayerGo;
myPlayerGo.transform.Find("Camerapivot").Find("Camera").GetComponent<Camera>().enabled = true;
usrText = GameObject.FindGameObjectWithTag("lobbyController").GetComponent<LobbyController>().userNmText;
myPlayerGo.GetComponent<PhotonView>().Owner.NickName = usrText.text;
myPlayerGo.GetComponent<PhotonView>().RPC("GetColor", RpcTarget.All, playerCol.r, playerCol.g, playerCol.b);
}

public override void OnPlayerEnteredRoom(Player newPlayer)
{
base.OnPlayerEnteredRoom(newPlayer);
player.GetComponent<PhotonView>().RPC("UpdatePlayerColor", RpcTarget.All, playerCol.r, playerCol.g, playerCol.b);
}
}
6 changes: 2 additions & 4 deletions Assets/Game/Scripts/PlayerController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

public class PlayerController : MonoBehaviourPunCallbacks
{
Color playerColor;
public Text nickname;
GameObject[] playerCrosshairs;
public GameObject[] allCars;
Expand Down Expand Up @@ -49,18 +48,17 @@ public class PlayerController : MonoBehaviourPunCallbacks
public bool isRunning = false;
public PhotonView pv;

public override void OnPlayerEnteredRoom(Player newPlayer)
/*public override void OnPlayerEnteredRoom(Player newPlayer)
{
base.OnPlayerEnteredRoom(newPlayer);
//PhotonNetwork.LocalPlayer.SetCustomProperties(WHAT DO I PUT IN HERE!!!!);
pv.RPC("UpdatePlayerColor", RpcTarget.All, playerColor.r, playerColor.g, playerColor.b);
}
}*/

void Start()
{
rb = GetComponent<Rigidbody>();
nickname.text = pv.Owner.NickName;
playerColor = GameObject.Find("GameSetup").GetComponent<GameSetupController>().playerCol;
//pauseMenu = GameObject.FindGameObjectWithTag("pausemenu");
//crosshair = GameObject.FindGameObjectWithTag("crosshair");
//pauseMenu.SetActive(false);
Expand Down

0 comments on commit 07d35bd

Please sign in to comment.