GentleMoa / P6_Spectroscopy

A sixth semester project from students of the Expanded Realities course of study at the h-da Hochschule Darmstadt.
4 stars 0 forks source link

Objects with PhotonView cannot be in the Multiplayer Scene from the get go #36

Closed GentleMoa closed 2 years ago

GentleMoa commented 2 years ago

Issue

Whenever there is a object with a "PhotonView" component in the multiplayer scene that is being loaded from the MainMenu, the game would break throwing the following errors:

1) "PhotonView ID duplicate found: 1. New: View 1 on Grab Interactable (scene) old: View 1 on RoomManager (scene). Maybe one wasn't destroyed on scene load?! Check for 'DontDestroyOnLoad'. Destroying old entry, adding new."

2) "InvalidOperationException: Duplicate key 1"

GentleMoa commented 2 years ago

After some research:

On our "PlayerManager" script, which handles spawning the respective VR/CAVE players is a "PhotonView" component with the original View ID of 1. This "PlayerManager" script is on a object ("RoomManager") which is inside the MainMenu scene and carries over to the multiplayer scene via a DontDestroyOnLoad function. This causes the issue because when the other objects containing a "PhotonView" component get assigned a View ID, they try to start at 1 again because this a new scene. Because RoomManager already occupies View ID 1, the "duplicate ID found" error gets thrown.

GentleMoa commented 2 years ago

Solution:

On the "RoomManager" object in the "PhotonView" component change the View ID from 1 to something really high like 998. This frees up the View IDs starting from 1.