Question about unity3d error

Options

Error code: PhotonNetwork.Instantiate() can only instantiate objects with a PhotonView component. This prefab does not have one: Player

The prefab exists in the resources folder. Script of creation:

using UnityEngine;

using Photon.Pun;


public class SpawnManager : MonoBehaviour

{

  public GameObject[] Spawns;


  public GameObject Player;


  private void Awake()

  {

    Vector3 randomPosistion = Spawns[Random.Range(0, Spawns.Length)].transform.localPosition;


    PhotonNetwork.Instantiate(Player.name, randomPosistion, Quaternion.identity);

  }

}

Everything worked out before, but when I replaced it with another prefab, this error started to come out. Help please!

Answers

  • AJ_Avocado
    Options

    Hello there!

    With PhotonNetwork.Instantiate(), you can only instantiate objects with a PhotonView component. You can add a PhotonView component on the inspector window (Add Component > PhotonView)

    Hope this helps!