InstantiateSceneObjects
How do I use Instantiate Scene Objects
Below are practical examples compiled from projects for learning and reference purposes
Featured Snippets
Line | Code | Ex.. |
---|---|---|
18 | if (!InstantiateSceneObjects) | 1 |
File name: OnJoinInstantiate.cs
Copy
13 public void OnJoinedRoom()
14 {
15 Vector3 pos = Vector3.zero;
16 pos.x += PhotonNetwork.player.ID;
17
18 if (!InstantiateSceneObjects)
19 {
20
21 newObj = PhotonNetwork.Instantiate(ObjectToInstantiate.name, pos, Quaternion.identity, 0, null);
22
23
24 // anything you do with newObj locally is not reflected on the other clients.
25 // you can add a script to the Prefab to do some instantiation in Awake() and you can call RPCs on newObj now.
26 }
27 else
28 {
29 newObj = PhotonNetwork.InstantiateSceneObject(ObjectToInstantiate.name, pos, Quaternion.identity, 0, null);
30 //PhotonView pv = newObj.GetComponent
31 //Debug.Log(pv.ownerId + " " + pv.viewID);
32 }
33 }
InstantiateSceneObjects 122 lượt xem
Gõ tìm kiếm nhanh...