Get data from master client.
Hello, What way I can get data from host? I need get spawn position.
I see it like this:
Request to Master Client and get callback from he with Vector2.
But better way without RPC. Can I do it with RaiseEvents?
I see it like this:
Request to Master Client and get callback from he with Vector2.
But better way without RPC. Can I do it with RaiseEvents?
0
Comments
-
Hi @RandomMan,
You can do it using RaiseEvent yes.
You should use a special event code for the event request (to MasterClient) and the event response (from MasterClient).
You can set the event target asraiseEventOptions.Receivers = ReceiverGroup.MasterClient
or usingraiseEventOptions.TargetActors = new int[1]{masterClientActorNr}
.
Then from the MasterClient use OnEvent to receive, process and send a response as an event. You can get the sender actorNr like thisint actorNr = (int)eventData[ParameterCode.ActorNr];
.0 -
Thanks!0
-
Okay, it works, but I found a bug. After leave room and joiun again it create me 4 tanks! and every join 4 tanks more, why is it happens?
https://pastebin.com/48aNAnEc
Check my code please!0 -
Really strange problem, it just MUST work but it is not!0
-
If Master Client disconnects it will be replaced by the actor with the next actor number if any.
When actors leave their instantiated GameObjects should be cleaned up by default.
What happens when Master Client sends event 0 to himself?
You should be able to track this down using useful logs.0 -
But I tested it only with 1 player and after leaving room got close0
-
Increase RoomOptions.EmptyRoomTTL (max 300000) and RoomOptions.PlayerTTL.0
-
As I told you if you are instantiating tanks the PUN way they should be deleted when actor leaves and nothing should be there if the room is closed!
You should ask yourself why tanks are still there when room is closed or when player has left.0 -
No tanks deleted! I checked it... All deleted already. The bug is event calling twice... I checked it by Debug.Log. I could fix it but by very bad way(just make integer and call event function only 1 time and if more than one time it will return) but it very bad way I think because events still will sending between player-host and eat no-need traffic. Just why they sending twice?0
-
Maybe events keep after leaving room in Client locally or something? and then they called multiple times(0
-
Please log the RaiseEvent calls of same event (add Debug.Log one line before or after with enough details to ID the event: e.g. sender + eventcode + target) then copy paste the logs of the duplicate calls with full stacktrace.0
-
Omg, I fixed that! the mitsake was that PhotonNetwork.OnEventCall+=OnEvent was calling every new join to Room and get 2x.4x.8x etc calling OnEvent! I just in OnLeaveRoom wrote PhotonNetwork.OnEventCall-=OnEvent.
Okay, my question is finally solved!0 -
Hi everyone,
I am also facing some kind of problem for PhotonNetwork.OnEventCall....
when client's disconnected due to network loss and reconnects then this method is called after reconnect = >
public void OnEvent (byte eventCode, object content, int senderId)
{
}0