- Home /
The question is answered, right answer was accepted
PhotonNetwork.Instantiate() doesn't work
Hello, sorry if I'm writing to wrong section, but anyway I can't instantiate player on network.
This is my script to connect:
using UnityEngine;
using System.Collections;
public class NetworkManager : Photon.MonoBehaviour {
public Transform respawn;
private const string _VERSION = "1.0";
void Start() {
PhotonNetwork.autoJoinLobby = false;
PhotonNetwork.ConnectUsingSettings(_VERSION);
}
public virtual void OnConnectedToMaster() {
PhotonNetwork.JoinRandomRoom();
}
public void OnPhotonRandomJoinFailed() {
PhotonNetwork.CreateRoom(null, new RoomOptions() { maxPlayers = 4 }, null);
}
public void OnJoinedRoom() {
Debug.Log(Resources.Load("Player"));
PhotonNetwork.Instantiate("Player", respawn.position, respawn.rotation, 0);
}
}
Using Debug.Log(Resources.Load("Player"));
placed inside of OnJoinedRoom() I've found out that it locates Player. But it won't instantiate. Instead, it instantiates default Unity 3rd person controller. Any idea why?
Answer by Magnomous · Mar 27, 2016 at 10:00 AM
I was instantiating prefab from Resources folder that was inside of Demo folder. So there were 2 Resources folders and it was instantiating from wrong one. Thank you for the answer anyway.
Answer by danthebeliever · Mar 26, 2016 at 07:41 PM
Make sure your prefab has a PhotonView attached.
i made that but it doesntt work now too. İ wish u didnt give up from unity .
Follow this Question
Related Questions
Photon Instantiate Prefab Script Problems 0 Answers
PhotonNetwork.InstantiateSceneObject works in editor but not in build 2 Answers
Photon Instantiate Group's, Instantiating Prefabs that should already Exist 1 Answer
Multiplayer game, object instantiated is being added for every single player 1 Answer