- Home /
player Spawning Error on Photon (PhotonNetwork.Instantiate)
Here is My Script;
using Photon.Pun; using UnityEngine;
namespace TestingPhoton { public class ComePlyr : MonoBehaviour { [Tooltip("The prefab to use for representing the player")] public GameObject playerPrefab;
void Start() {
if (playerPrefab == null)
{
Debug.LogError("<Color=Red><a>Missing</a></Color> playerPrefab Reference. Please set it up in GameObject 'Game Manager'", this);
}
else
{
// we're in a room. spawn a character for the local player. it gets synced by using PhotonNetwork.Instantiate
PhotonNetwork.Instantiate(playerPrefab.name, transform.position * Random.Range(0, 2), Quaternion.identity);
}
}
}
}
in the Editor Showing error on Join GameRoom 1[DefaultPool failed to load "player" . Make sure it's in a "Resources" folder. UnityEngine.Debug:LogError(Object)] 2[NullReferenceException: Object reference not set to an instance of an object]
Photon.Pun.DefaultPool.Instantiate (System.String prefabId, UnityEngine.Vector3 position, UnityEngine.Quaternion rotation) (at Assets/Photon/PhotonUnityNetworking/Code/PunClasses.cs:997) Photon.Pun.PhotonNetwork.NetworkInstantiate (Photon.Pun.InstantiateParameters parameters, System.Boolean sceneObject, System.Boolean instantiateEvent) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetwork.cs:2447) Photon.Pun.PhotonNetwork.Instantiate (System.String prefabName, UnityEngine.Vector3 position, UnityEngine.Quaternion rotation, System.Byte group, System.Object[] data) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetwork.cs:2346) TestingPhoton.ComePlyr.Start () (at Assets/Script/ComePlyr.cs:19)
in Unity I Try in //Diffrents of Way //Use other Script //change, Create New Project //Try to Diffrent unity Version out of three Days Showing Error and show same error !Please Give Your Answer&Openion Please
Answer by vilajaume4 · May 24, 2020 at 03:01 PM
May you have to create a folder which must be called "Resources" then drop there your character prefab and run the game.
Still not working! I got the same error. It appears all of a sudden. Like Photon is shit
Your answer
Follow this Question
Related Questions
Player names all displayed as local player 1 Answer
Player prefab instantiation 1 Answer
Distribute terrain in zones 3 Answers
This Code Does Not Spawn A Player Why? 1 Answer
Photon Network, how to spawn FPSController from Unity Standard Assets? 2 Answers