The Photon Forum
is Closed Permanently.

After many dedicated years of service, we have made the decision to retire our Forum and switch to read-only: we´ve saved the best to last! Your search result can be found below. Plus, we offer support via these channels:

Try Our
Documentation

Please check if you can find an answer in our extensive documentation on PUN.

Join Us
on Discord

Meet and talk to our staff and the entire Photon-Community via Discord.

Read More on
Stack Overflow

Find more information on Stack Overflow (for Circle members only).

Write Us
an E-Mail

Feel free to send your question directly to our developers.

RaiseEvent OnEvent() not firing

zforest
2019-03-30 19:54:38

I'm following
https://doc.photonengine.com/en-us/pun/current/gameplay/instantiation

I made a MonoBehaviour that implements IOnEventCallback and has functions that both calls RaiseEvent, and the OnEvent() function just like the above doc.

Then in my OnEvent(), it is called with event code 255,206,210, etc.. But never goes inside the if() with CustomManualInstantiationEventCode=123

  public void OnEvent(EventData photonEvent)  
    {  
        if (photonEvent.Code == CustomManualInstantiationEventCode)  
        {...}  
}

My MonoBehaviour implements IOnEventCallback and has

  
public void OnEnable()  
{  
    PhotonNetwork.AddCallbackTarget(this);  
}

public void OnDisable()  
{  
    PhotonNetwork.RemoveCallbackTarget(this);  
}

Comments

JohnTube
2019-04-01 13:23:24

Hi @zforest,

Thank you for choosing Photon!

How do you call RaiseEvent?
Do you want to receive events from the same player or from another player? If you want to receive it from the same player who sends the event, you need to set this explicitly as the default behaviour sends event to others e.g. RaiseEventOptions.Receivers = ReceiverGroup.All.

zforest
2019-04-01 14:02:14

hi @JohnTube

I followed the guide and used ReceiverGroup.Others
when that did not work, I also tried ReceiverGroup.All
but no dice either. Would be good if there is a way to debug this. Thanks

JohnTube
2019-04-01 14:15:25

Hi @zforest,

Do you see anything useful in the logs? warning or error?
Are you calling PhotonNetwork.RaiseEvent when joined to a room? it works only inside rooms.
PhotonNetwork.RaiseEvent returns boolean.
Make sure it returns true.


Then in my OnEvent(), it is called with event code 255,206,210, etc.
The list of event codes. I can see that 255 is Join event. Are you connecting to Photon public cloud? which region? 210 is obsolete and should not be received, please make sure you are really receiving this event. 206 is not a predefined native Photon event.

EDIT:
nevermind what's after "---"
210 and 206 are PUN events and not Realtime events:

internal class PunEvent  
    {  
        // [...]  
        public const byte SendSerializeReliable = 206;  
        // [...]  
        public const byte OwnershipTransfer = 210;

MeatyMario
2023-02-18 03:31:27

I know it's an old one, but if anyone might come here looking for a solution here it is:

You need an IOnEventCallback interface and AddCallbackTarget in OnEnable/OnDisable

All here: https://doc.photonengine.com/pun/current/gameplay/rpcsandraiseevent

Back to top