0

Exception: Write failed. Custom type not found: AINavmesh ExitGames.Client.Photon.Protocol18.WriteCustomType (ExitGames.Client.Photon.StreamBuffer stream, System.Object value, System.Boolean writeType) (at C:/Dev/photon-sdk-dotnet/PhotonDotNet/Protocol18Write.cs:741)

private void OnTriggerEnter(Collider other)
    {
        if (!pv.IsMine)
        {
            return;
        }
        if (other.gameObject.CompareTag("AINavmesh")){
            
           AINavmesh navmesh = other.gameObject.GetComponent<AINavmesh>();
            Debug.Log("NavmeshId" + navmesh.player_ID+"this attackId"+attackID);
            pv.RPC("DamageRPC", RpcTarget.AllBuffered, navmesh);
        }
    }

    [PunRPC]
    public void DamageRPC(AINavmesh navmesh)
    {
        navmesh.health -= damage;
        Debug.Log("Navmeshhealth" + navmesh.health);
        PhotonNetwork.Destroy(this.gameObject);
    }
avariant
  • 2,234
  • 5
  • 25
  • 33
  • 1
    From their documentation, Photon doesn't automatically serialize complex types. You will have to create a custom serializer. – avariant Apr 06 '23 at 13:19
  • Don't pass components over the network. Use GetComponent or similar from the RPC function. Pass enough information to be able to find that component from the remote instances. Something like an id on your script so you can do something akin to `DamageRPC(long id) { var aiNavMesh = GetAINavMeshFromId(id); }` and have a lookup table with the id as a key. I am not sure that passing a component over the network would even work. Either way its more information than needed on the network. – hijinxbassist Apr 07 '23 at 00:06

0 Answers0