When you join a room, it spawns the player and enables the components that let him move and shoot. I also enables the Camera which is a child to the player.
The script worked fine on an earlier project, but now it just isn’t working. (Maybe because of unity 5?) I can still run the game with no compiler errors. I do get one error towards the script = InvalidCastException: Cannot cast from source type to destination type.
Here is the section of the script =
void SpawnMyPlayer() {
Debug.Log ("SpawnMyPlayer");
GameObject myPlayerGO = (GameObject)PhotonNetwork.Instantiate("Player", SpawnSpot.transform.position,SpawnSpot.transform.rotation, 0);
standbyCamera.enabled = false;
((MonoBehaviour)myPlayerGO.GetComponent("FirstPersonController")).enabled = true;
((MonoBehaviour)myPlayerGO.GetComponent("CharacterController")).enabled = true;
((MonoBehaviour)myPlayerGO.GetComponent("Shootscript")).enabled = true;
myPlayerGO.transform.Find("MainCamera").gameObject.SetActive(true);
}
So the components refuse to enable, and I can’t get the Camera to enable either.
I’m using Photon
Thanks for you time!