Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
2
Question by Wernight · Mar 03, 2010 at 08:38 AM · rpc

RakNet RPC calls between C++ and Unity

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?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by Wernight · Mar 03, 2010 at 09:06 AM

By trial and error I found this:

In Unity (C#):

[RPC]
MyRPC
void MyRPC(int a, float f, string s)
{
    // Dummy, only used in the C++
}

In 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)

 int a;
 bits.Read(a);

 float f;
 bits.Read(f);

 char s[100];
 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.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by kilkis · Jun 22, 2011 at 02:04 AM

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",∈Bitstream, 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!

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

1 Person is following this question.

avatar image

Related Questions

How can I get deep info on configuration of Unity networking? 0 Answers

OnSerializeNetworkView issus in my 2D game 3 Answers

Does Unity merge RPC calls into one packet per tick? 0 Answers

Unet Bufferd RPC 0 Answers

Easy way to make my own Simple Master Server? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges