How to let clients see each other?

Hello,



If client#1 connects to server and then client#2 connects. How does client#1 see client#2 ? Iv used rootNode.attachChild(// code for adding my new hero) to let client#1 see client#2. It works but after adding client#2, client#1 cannot control his own hero, it controls the new hero. (hope i describe this clearly…)



What code can I use to make client#1 see client#2 when client#2 connects.

This is some really basic networking stuff ! You should go and read some more on the web about this topic.

But basically you can do something like this:

client connects → server stores all “connected” clients → server sends the list of “connected” clients(and their state like position etc) to the ones that just connected



When your local “player” is be instantiated, mark him with a flag like isLocalPlayer or mark the ones you get “sent” by the server with isRemotePlayer.



Also don’t forgot, you don’t have to iinstantiate a complete “player” control for the remote players. (You don’t need the input controls and stuff) Because all you want to do is “fake” that remote player. I.e. just having a model and set it’s position or animations. Based on that remoteClients info.

1 Like

@terry90 Thanks for your help~

Can I say that when client#2 connected ( client#1 is already connected), the server could broadcast/send message(the message is the list of “connected” clients) to client#2 to tell him client#1 is here ?

And for remote player(s) or showing actions of client#2 on client#1’s screen: when client#2 moves forward for example, client#2 sends message to server that “moving forward” then server sends this message to client#1 and client#1 gets this message to let client#2’s hero which is on client#1’s screen move forward? @_@ (my words looks complicated)?



Thank you again~

Have you looked at the networking examples, they can often be very useful.

@garlicbread said:
@terry90 Thanks for your help~
Can I say that when client#2 connected ( client#1 is already connected), the server could broadcast/send message(the message is the list of “connected” clients) to client#2 to tell him client#1 is here ?
And for remote player(s) or showing actions of client#2 on client#1's screen: when client#2 moves forward for example, client#2 sends message to server that "moving forward" then server sends this message to client#1 and client#1 gets this message to let client#2's hero which is on client#1's screen move forward? @_@ (my words looks complicated)?

Thank you again~


Yes, yes,... and yes :P maybe format your questions a bit better to make them more readable(like using new lines and stuff)

You should really look at a few more examples. There are some good sources on the web, you just need to google for something like: 'game development networking'

Once you got the hang of the basic networking, you could take a look at the MonkeyZone sourcecode (just google for it or browse through the JME repository). It is a working example and shows you some common techniques used for networking.

Good luck on your approach!
Once you got the hang of the basic networking, you could take a look at the MonkeyZone sourcecode (just google for it or browse through the JME repository). It is a working example and shows you some common techniques used for networking.


I don't think it's considered working copy atm. More like an early alpha. Maxes out at about 5 fps currently for me, and all I saw was a small terrain with 2-3 moving objects.