Players who join later, will initially instantiate the object at this place, even if it moved already.Īny prefab must have a PhotonView component. The position and rotation where to create the object must be set. Internally, PUN will fetch the GameObject from the PhotonNetwork.PrefabPool, set it up for the network and enable it. The first parameter of PhotonNetwork.Instantiate is a string which defines the "prefab" to instantiate. PhotonNetwork.Instantiate("MyPrefabName", new Vector3(0, 0, 0), Quaternion.identity, 0) To create networked GameObjects, use PhotonNetwork.Instantiate instead of Unity's Object.Instantiate.Īny client in a room can call this to create objects which it will control. This page and the following ones explain how to create, sync. PUN 2 can use a pool to create (and return) them.Įach networked GameObject must have a PhotonView component (and a ViewID) as identifier via the network. PUN provides a convenient way to do just that.Īs usual in Unity, Instantiate and Destroy are used to manage the lifetime of GameObjects. Maybe it's a character, some units or monsters that should be present on all clients inside a room. Most multiplayer games need to create and synchronize some GameObjects.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |