Get PhotonView through Player object / Get all PhotonViews in current room

I'm having a case where I need to acess each player's photon-instantiated gameobject in a room in short intervals. I figured I could do this via

PhotonNetwork.CurrentRoom.Players

and then grab each player's individual PhotonView Component, until I figured that the Player object doesn't seem to support any functionality to do so. Am I missing something or is this just impossible?

Alternatively I'd also take some functionality to get all PhotonViews in the current room, but apart from

FindObjectsOfType<PhotonView>()

which could kill my performance, there seems to be none as well. Does someone have an idea how to do so in a reasonably performant way?

Answers

  • I would propose creating a list to hold the players in the room then adding to the list as a player enters through an RPC. Then run your intervals locally (preferably for performance), or through a stream, by just searching through the list of players.