Looking in the forum old topics seems to tell that Unity3D does the same as RakNet RPC3 without using AutoRPC nor RPC3.
Like other I'd like to transmit data between Unity and a server in C++ on Linux. There are many reasons for that, like performance, OS portability, memory usage, flexibility, reliability...
After receiving a RPC call in C++ from Unity, I have `RPCParameters* rpcParms` but those are the compressed bitstream generated by Unity. Is there a C++ utility to decompress them?
By trial and error I found this:
In Unity (C#):
void MyRPC(int a, float f, string s)
// Dummy, only used in the C++
static void MyRPC(RPCParameters* rpcParms)
size_t byteCount = (rpcParms->numberOfBitsOfData + (8-1)) / 8
RakNet::BitStream bits(rpcParms->input, byteCount, false);
bits.IgnoreBits(20); // Skip some unknown bit (2 and half bytes in fact)
StringCompressor* sc = StringCompressor::Instance();
sc->DecodeString(s, sizeof(s)/sizeof(char), &bits, 0);
This will read all the parameter send by a RPC call from Unity. The reverse also work: Making a RPC call from C++ to Unity.
Note: I didn't include all the RakNet elements. You'll have of course to initialize RakNet and process the messages in your main loop etc., just as RakNet says. A good starting point is the C++ master server for Unity source code.
For some reasons I must make my server in C++ and RakNet,so I do it like this in C++: RakNet::BitStream reply; NetworkID nid; nid.guid = peer->GetGuidFromSystemAddress(packet->systemAddress); peer->RPC( “testRPC”,&inBitstream, HIGHPRIORITY,RELIABLEORDERED,0,packet->systemAddress,false,0,nid, &reply);
but,unity3d tell me that “Internal RPC error. Network ID used for static RPC function, function incorrectly called.”, and I can’t find anything about it,so I hope anyone knows it to help me,thank you!