ParaToxic Posted November 26, 2011 Share Posted November 26, 2011 Hello community, first big thank to Engineer Ken for the good Raknet tutorial. I would like to send an receive a little struct with the position and the rotation of an entity. I made it like this to send : struct Player { float a,b; }; //....... Player pl; pl.a = 12.0f; pl.b = 4.5f; //...... server->server->Send(reinterpret_cast<char*>(&pl),sizeof(pl), HIGH_PRIORITY, RELIABLE_ORDERED, 0, RakNet::UNASSIGNED_SYSTEM_ADDRESS, true); For the client i don't know how to convert the client->p->data to a created "Player" struct like pl2. Maybe somebody can tell me how to do that. Thanks ;D Quote Link to comment Share on other sites More sharing options...
Rick Posted November 26, 2011 Share Posted November 26, 2011 Are you doing this in 2D? You only have a and b. I would expect 2 x, y, z for position and rotation. Given you really need x, y, z use BitStreams. In fact use BitStreams no matter what. It's what's recommended. It also has WriteVector() and ReadVector() function build into it to write x, y, z and read x, y, z values. http://www.jenkinssoftware.com/raknet/manual/bitstreams.html Quote Link to comment Share on other sites More sharing options...
ParaToxic Posted November 26, 2011 Author Share Posted November 26, 2011 I sent my structure successfully when I copy the client to an other PC in at my home it can't connect. In the Client properties I have my IP which is listed by the server under IP adresses at place 1. Maybe somebody can tell me why? I think the problem is the Socket IP,which is 127.0.0.1 ,so localhost.How can I solve that? Thanks and good night ;D Quote Link to comment Share on other sites More sharing options...
Road Kill Kenny Posted December 5, 2011 Share Posted December 5, 2011 I sent my structure successfully when I copy the client to an other PC in at my home it can't connect. In the Client properties I have my IP which is listed by the server under IP adresses at place 1. Maybe somebody can tell me why? I think the problem is the Socket IP,which is 127.0.0.1 ,so localhost.How can I solve that? Thanks and good night ;D Hi Para Toxic, I would highly reccomend sending BitStreams instead of Structs. I don't think I ever send structs at all. If the IP u are using to connect is 127.0.0.1 then you are networking with yourself. If you are trying to network between 2 computers you need to determine the semi-dynamic IP of the server computer (something like 192.168.x.x)and connect to that instead. If you want over the internet you need the fully dynamic IP. Some day I will write a tutorial on how to to do LAN server discovery so you don't have to hard code the IP addresses but that is for another day. In the meantime you can look at the example LAN server discovery code that comes with RakNet. Quote STS - Scarlet Thread Studios AKA: Engineer Ken Fact: Game Development is hard... very bloody hard.. If you are not prepared to accept that.. Please give up now! Link to comment Share on other sites More sharing options...
ParaToxic Posted December 12, 2011 Author Share Posted December 12, 2011 Ok I made my first little Multiplayer Game Thank you for support and the great Tutorials ;D Quote Link to comment Share on other sites More sharing options...
Road Kill Kenny Posted December 13, 2011 Share Posted December 13, 2011 Ok I made my first little Multiplayer Game Thank you for support and the great Tutorials ;D gratz Ok I made my first little Multiplayer Game Thank you for support and the great Tutorials ;D gratz Quote STS - Scarlet Thread Studios AKA: Engineer Ken Fact: Game Development is hard... very bloody hard.. If you are not prepared to accept that.. Please give up now! Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.