PUN issue with playerlist
@Tobias
I added few bots in the game as players by
now when the bot loses the game I want to kick him so I am calling
but PhotonNetwork.CurrentRoom.Players, PhotonNetwork.PlayerList, PhotonNetwork.CurrentRoom.PlayerCount nothing is being affected I am not able to remove the bots from the game from the master client
So is there a different way to add bots as players since I need to use PUNTurnManager or a way to remove bots from the playerlist?
I added few bots in the game as players by
PhotonNetwork.CurrentRoom.AddPlayer(bot); //bot is derived from Photon.Realtime.Player
now when the bot loses the game I want to kick him so I am calling
PhotonNetwork.CloseConnection(bot);
but PhotonNetwork.CurrentRoom.Players, PhotonNetwork.PlayerList, PhotonNetwork.CurrentRoom.PlayerCount nothing is being affected I am not able to remove the bots from the game from the master client
So is there a different way to add bots as players since I need to use PUNTurnManager or a way to remove bots from the playerlist?
0
Best Answers
-
Sorry to say but adding bots as players is probably not a good idea.
PUN and the Realtime API expect that each Player refers to a specific connected player. One you can send events to, etc. If this is not the case, things may behave weird.
AddPlayer is public to enable PUN to setup an "offline room". Sorry for this misleading API choice. We can probably solve that in a different way to make things more obvious.
CloseConnection attempts to send a message/event to said player and will fail.
RemovePlayer is doing the work locally only. I hope that works.5 -
Those components are not done with bots in mind, which is why we can't provide code for this right now.
It will take a while until we can focus our attention on those parts again.
As for the solution to your situation: You really have to come up with a system yourself. You got Custom Properties to simply store key-values. You can define your own events to send custom content, too.
The TurnManager code is sample code and you can copy and modify it for your Photon games.5
Answers
-
Sorry to say but adding bots as players is probably not a good idea.
PUN and the Realtime API expect that each Player refers to a specific connected player. One you can send events to, etc. If this is not the case, things may behave weird.
AddPlayer is public to enable PUN to setup an "offline room". Sorry for this misleading API choice. We can probably solve that in a different way to make things more obvious.
CloseConnection attempts to send a message/event to said player and will fail.
RemovePlayer is doing the work locally only. I hope that works.5 -
So I won't be able to use any photon player lists or dictionary for any functionality, for turnmanager I will have to create my own list by adding players and bots into that list? I am using actor number, nickname and many more parameters of Player class for almost everything
Is there a better way to tackle this issue? what is the best way to add bots???
Its a turn base card game.0 -
Those components are not done with bots in mind, which is why we can't provide code for this right now.
It will take a while until we can focus our attention on those parts again.
As for the solution to your situation: You really have to come up with a system yourself. You got Custom Properties to simply store key-values. You can define your own events to send custom content, too.
The TurnManager code is sample code and you can copy and modify it for your Photon games.5