Quantcast
Channel: Photon Unity Networking (PUN) — Photon Engine
Viewing all articles
Browse latest Browse all 8947

Can't get instantiation to work

$
0
0
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:

public void NewDraft ()
{
Draw = new GameObject[amountOfCardsToDraw];
CurrentDraft = new List();
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().group = ParentObject.GetComponent();
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?

Viewing all articles
Browse latest Browse all 8947

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>