- Home /
Question by
Hedonsoft · Jul 15, 2014 at 11:28 PM ·
instantiateprefabphoton
Photon.Inatantiated() player prefab loses control
I have a player prefab with controls setup and it works fine if I drag it into the scene, however if I Instantiate it like this in my NetworkManager.cs it spawns, but I can't control it.
public class NetworkManagerCW : MonoBehaviour {
public GameObject standByCamera;
SpawnSpot[] spawnSpots;
// Use this for initialization
void Start () {
spawnSpots = GameObject.FindObjectsOfType<SpawnSpot>();
Connect();
}
void Connect()
{
PhotonNetwork.ConnectUsingSettings("Test Serverv001");
}
void OnGUI()
{
GUILayout.Label(PhotonNetwork.connectionStateDetailed.ToString());
}
void OnJoinedLobby()
{
PhotonNetwork.JoinRandomRoom();
}
void OnPhotonRandomJoinFailed()
{
PhotonNetwork.CreateRoom(null);
}
void OnJoinedRoom()
{
Debug.Log("OnJoinedRoom");
SpawnMyPlayer();
}
void SpawnMyPlayer()
{
if (spawnSpots == null)
{
Debug.LogError("WTF");
return;
}
SpawnSpot mySpawnSpot = spawnSpots[Random.Range(0, spawnSpots.Length)];
PhotonNetwork.Instantiate("SimplePlayer", mySpawnSpot.transform.position, mySpawnSpot.transform.rotation, 0);
standByCamera.SetActive(false);
}
}
I checked the player while the game is running and all scripts are enabled.
screen.png
(99.2 kB)
Comment
Best Answer
Answer by Hedonsoft · Jul 15, 2014 at 11:37 PM
Got it. There was a line in a script I had to take out because I wasnt using it.