Can't get instantiation to work
Options
Hey there,
In my scene I have a bunch of Card gameobjects (that all derive from the same prefab, the contents of them have been altered in the editor). Now, I'm using a method called NewDraft to spawn the cards:
Could you help me with this please?
In my scene I have a bunch of Card gameobjects (that all derive from the same prefab, the contents of them have been altered in the editor). Now, I'm using a method called NewDraft to spawn the cards:
public void NewDraft () { Draw = new GameObject[amountOfCardsToDraw]; CurrentDraft = new List<GameObject>(); for (int x = 0; x < amountOfCardsToDraw; x++) { LengthOfList = CompleteDeck.Count; CardType = Random.Range(0, LengthOfList); GameObject card = GameObject.PhotonNetwork.Instantiate(CompleteDeck[CardType]) as GameObject; card.transform.SetParent(ParentObject.transform) ; card.GetComponent<Toggle>().group = ParentObject.GetComponent<ToggleGroup>(); Draw[x] = card; CompleteDeck.RemoveAt(CardType); CurrentDraft.Add(card); } }When I try to use the PhotonNetwork.Instantiate I get the error that 'GameObject' does not contain a definition of PhotonNetwork. I'm using the Photon namespace and I've added the Photonview script to the prefab that the cards are created from (so all the cards have it).
Could you help me with this please?
0
Comments
-
Hi nidhogge242,
please take a look at the docs over here: https://doc.photonengine.com/en/pun/current/tutorials/instantiation
There is an example on how Network Instantiation works, since it is slightly different than in Unity itself.0