How do you make a custom spawn script in the new Photon Fusion
Options
in Fusion
Hello, so in our previous game we had this script for spawning objects when using Pun2:
public void SpawnPlayer(string PlayerPrefab, int PlayerID) { Transform spawnpoint = FindSpawnPoint(GameObject.FindGameObjectsWithTag("SpawnPoint"), PlayerID); Vector3 position = spawnpoint == null ? Vector3.zero : spawnpoint.transform.position; Quaternion rotation = spawnpoint == null ? Quaternion.identity : spawnpoint.transform.rotation; Debug.Log("Spwaning \"Local" + PlayerPrefab + "\" at position " + position + " and rotation " + rotation.eulerAngles); GameObject player = GameObject.Instantiate((GameObject)Resources.Load("Local" + PlayerPrefab), position, rotation); PhotonView photonView = player.GetComponent<PhotonView>(); if (PhotonNetwork.AllocateViewID(photonView)) { object[] data = new object[] { PlayerPrefab, position, rotation, photonView.ViewID }; RaiseEventOptions raiseEventOptions = new RaiseEventOptions { Receivers = ReceiverGroup.Others, CachingOption = EventCaching.AddToRoomCache }; PhotonNetwork.RaiseEvent(69, data, raiseEventOptions, SendOptions.SendReliable); } else { Debug.LogError("Failed to allocate a ViewId."); GameObject.Destroy(player); } } public void OnEvent(EventData photonEvent) { if (photonEvent.Code == 69) { object[] data = (object[])photonEvent.CustomData; Debug.Log("Spwaning \"Online" + (string)data[0] + "\" at position " + (Vector3)data[1] + " and rotation " + ((Quaternion)data[2]).eulerAngles); GameObject player = GameObject.Instantiate((GameObject)Resources.Load("Online" + (string)data[0]), (Vector3)data[1], (Quaternion)data[2]); PhotonView photonView = player.GetComponent<PhotonView>(); photonView.ViewID = (int)data[3]; } }
Now we decided to use the new Photon Fusion because it is the more supported / stable version, but how can we remake this script in the new version. Most of the functions in Fusion seem to be in DLLs, so we can't really find a way to check how your spawning works and how to make our own
Having spawning like this sped up our workflow quite a bit, so we hope this is possible to do!
0
Answers
-
Forgot to mention that this is an old version of the script I found. So just ignore the "FindSpawnPoint()" function since we never ended up using it and made a better spawnpoint system.
0