Custom network events.
Options
Comments
-
This has a number of the events that you may find helpful:
http://doc-api.exitgames.com/en/realtim ... 440ebdbc880 -
Thanks for commenting.
if either already took account of this before, but what I want is to create my own events like these (if possible).0 -
Hi,
Send events with PhotonNetwork.RaiseEvent(...) and receive them with method registered in PhotonNetwork.OnEventCall.
See PhotonNetwork.RaiseEvent help for details0 -
sorry for the late reply and Thank you for replying.
thank you very much @vadim is exactly what I wanted.
I read the documentation, I can now just ask if I can confirm that this would be a correct way to use it, please.
first register the event:void OnJoinedRoom(){ if(PhotonNetwork.isMasterClient){ PhotonNetwork.OnEventCall += this.OnEventRaised; Debug.Log(" registered new event"); } }
then for events I have this:public void OnEventRaised(byte eventID, object customInfo, int PlayerID) { Debug.Log("Recive this eventid "+eventID+"with this info "+customInfo+"from : "+PlayerID); if(eventID == (byte)1){ //only example CallmyCustomFunction(customInfo); } }
I wonder if this is a correct way to use this method ...?
to by the way, also I have a problem sending the event, and is the player who sends the event does not recive the event, how can I fix this ..?
Thank you.0 -
You set up only master client for receiving events. Is that what you want? If so then you should send event from master too if you want receive event on sender. But it's hardly makes sense.
Better subscribe all clients to events and target client when sending (save bandwidth). Or skip handling in OnEventRaised by condition (if non-master e.g.)0