RaiseEvent is the right tool?

Options
Hi!

I'm using PUN in an collaborative VR Scene and got some trouble to implement it in my existing Scene.

I've got a Script in which i create a new Gameobject (Marker) on Triggerpress. This Triggerpress should occur also on the Client and so i tried to solve this with RaiseEvent regarding this tutorial https://doc.photonengine.com/en-us/pun/current/gameplay/rpcsandraiseevent.
My code:

if(LaserPointScript.Trigger)
{
byte evCode = 1;
PhotonNetwork.RaiseEvent(evCode, hit.point, true ,null); //hit.point = The impact point where the where the ray hit the collider
MarkerErzeugen(hit.point);//Generate Marker
}
Then i receive the Even in the same Script with :

private void OnEnable()
{
PhotonNetwork.OnEventCall += this.OnEvent;
}
private void OnDisable()
{
PhotonNetwork.OnEventCall -= this.OnEvent;
}

void OnEvent(byte eventcode, Vector3 content, int senderid)
{
if (eventcode == 0)
{
PhotonPlayer sender = PhotonPlayer.Find(senderid); // who sent this?
Debug.Log(sender);

MarkerErzeugen(content); // Generate Marker



}
}

void MarkerErzeugen(Vector3 hitPoint) {
HERE I GENERATE MY MARKER...
Compiling errors are CS0123 C# No overload for matches delegate for
PhotonNetwork.OnEventCall += this.OnEvent; and
PhotonNetwork.OnEventCall -= this.OnEvent;

I'am not sure if i use the right tool to achieve that the TriggerPress form Master is also sent to Clienet. I'm also pretty sure, that i can't use a none Object class in RaiseEvent like i did with Vector3.

Every help very much appreciated

Answers

  • Napa
    Options
    So i found another Thread who also used RaiseEvent and could get some infomation from it.

    What i changed to make it work (yes, it works):
    HitPointContent = hit.point;
    PhotonNetwork.RaiseEvent(evCode,new object[] { HitPointContent }, true, new RaiseEventOptions() { Receivers = ReceiverGroup.All, CachingOption = EventCaching.AddToRoomCache });

    void OnEvent(byte eventcode, object content, int senderid)
    {
    if (eventcode == 1)
    {
    object[] data = (object[])content;
    HitPointContent = (Vector3)data[0];
    PhotonPlayer sender = PhotonPlayer.Find(senderid); // who sent this?
    Debug.Log(sender);
    MarkerErzeugen(HitPointContent); // Generate Marker
    Debug.Log("eventcode == 1 wurde aufgerufen");
    }