Create player controls or objects dynamically

Hello mates! I am sure this is a very noobish question, but I was wondering if there was a way to create player controls or objects dynamically. As in, say a new player joins, it would automatically create a player control for them and their objects (armor, weapons, etc) when they enter instead of me having to declare them in the code. Sorry if this is a bad question but thanks for your help anyways!

Excuse me, Character Control*
Not player control

you are talking about “a new player join”, but there is nothing like “default multiplayer” stuff in jme. If you want to have anything like a multiplayer game you’ll have to do it yourself.

So, the answer is “no”, and it’s even worse than that : the answer is no AND even if you create a new charactercontrol there is no “easy” way to attach it to an other keyboard somewhere else on the network.

And, yes, it’s a noobish question, but there is nothing wrong in being a noob. I can only suggest you to create your own tetris game, to start (and without jme, it wouldn’t help you in that). You can create a pretty nice tetris game in less than a day. Then, you can create a doodle jump, to understand what is “collision” and “physic” etc. Then, create a simple multiplayer game (like a card game) with the basic api io in java. Yes, for this one you’ll have maybe weeks of headache but then you’ll be happy.

After all of this, the “multiplayer 3D game” will not be that far.

For the record, i am myself creating a multiplayer game (even if this week i have stuff irl to do, like painting XD) and there is 20k lines of code to have something that start to be “nice”. And i more than likely need the double of that to achieve what i want.

I have made my server so that it receives the walkDirection and input from the client, and translates it onto the server’s instance. It then sends the coordinates back to each client. Do you believe this method is viable? I have messed around with Jme before, but this whole client server thing (ie networking) is evil! And I haven’t even scratched the surface yet…

This is viable (i think) BUT :

  1. you’ll get trouble soon about the network thread client (and server) -side. What i mean is : the thread that receive the message is not the “gui” thread, so you cannot modify the scenegraph from it. For messages that doesn’t modify the scenegraph it’s fine, but for the others it’s just hell.

You can use my “messagedispatcher” class which is more or less a queue that get the message and store it and flush them in the main loop. You loose the “multi-thread” part, but if you do that only for messages which need to modify the scenegraph anyway it’s not a big deal.

  1. If you translate things like that you’ll get warp as soon as you’ll get lag from the server (and it will happen soon). Also, when you find normal to have a 60 fps in a game, you’ll rarely get more than 20 or 30 message per second (and you shouldn’t have so much message per second). So, if you want to avoid the “warp” effect, you should use an interpolationcontroller client-side. This will also help you when you’ll cap the server’s loop’s speed (and then create “lag”).

  2. You SHOULDN’T do that for the camera, at least it’s my opinion. Let me explain myself : when the movement of the character is a bit glitchy, it’s not a real problem, you’ll not get sick because of that. But, if when you move your camera you have latency and lags, it’s almost unbearable. It’s my opinion. For here, i chose to let the client turn his camera, then the client send to the server the new orientation and the server echoes it to other clients. The problem in this approach is : this is a big breach for aim bots.

(the source of my project is here : http://sourceforge.net/p/realgame/code/ci/master/tree/

the class messagedispatcher is here http://sourceforge.net/p/realgame/code/ci/master/tree/src/real/common/tools/MessageDispatcher.java
but its use is a bit glitchy and i don’t have time to explain it now. But you get the idea and maybe you should try to create something equivalent yourself.

the class interpolationcontroller is here http://sourceforge.net/p/realgame/code/ci/master/tree/src/real/client/controllers/InterpolationController.java
but it’s also still a wip.)

  1. later (very later) you’ll maybe want to add some extrapolation client-side to diminish the latency. However, this is a source of bugs and headaches.

  2. Physics through networks is something very hard to do, and it’s why most of games out there only provide visual effect for dynamic things (like ragdoll for dead body) and use mostly static things for “real” stuff. Actually, i theorized this a lot but it’s a very broad topic and way too hard to explain in english (not my native language) and at 1:58 o’clock.

1 Like

Wow, thanks for all the help! Actually, I did what you said in 3 but I never thought of Aim bots. I hope they wouldn’t be used for a non-fps game but since there is fighting, I can assume it will be a problem. I will DEFINITELY look into everything you have said. You are the first person I have met that has actually given advice to me about this. Thanks again and goto bed! Here, it is only 8:30.
Also, your english is really good considering it is not your native language!

@IdreesInc said: You are the first person I have met that has actually given advice to me about this.

It may be fatigue from answering so many times only to find out that the person gives up when they discover that it’s 1000 times harder than they expected. If this is your first time at a networked game (let alone a real time one) then you won’t even really know how hard it is until you’re debugging things 6 months from now.

Anyway, that being said, here are the standard links provided for those who are serious about the subject:
https://developer.valvesoftware.com/wiki/Source_Multiplayer_Networking
https://developer.valvesoftware.com/wiki/Latency_Compensating_Methods_in_Client/Server_In-game_Protocol_Design_and_Optimization

They probably take 3 or 4 reads to really ‘get it’. The concepts are pretty critical for a real time game, though.

1 Like

Yup, I have been sick for the whole week and have had a lot of time on my hands. I found this topic and found the links you mentioned. It actually mentioned the method I was going to use at first until everyone explained how un-scaleable it was and directed me on the right approach. I read the links and it explained a lot but I (obviously) don’t understand a few of the concepts and I am looking into them. Also, in relation to the topic mentioned, it is my goal to not be like the topic’s author and argue against those who actually know there stuff. Since I seem to run across you a lot, please tell me when I am repeating the author’s mistake. Thanks for being so patient with me

EDIT: As to the whole ‘‘giving up’’ thing, I am quite young (16) and though this makes me especially prone to the urge to give up, I believe it allows me to have time to get it right. I guess I all I can do is wait and work at it!

@IdreesInc said: Yup, I have been sick for the whole week and have had a lot of time on my hands. I found this topic and found the links you mentioned. It actually mentioned the method I was going to use at first until everyone explained how un-scaleable it was and directed me on the right approach. I read the links and it explained a lot but I (obviously) don't understand a few of the concepts and I am looking into them. Also, in relation to the topic mentioned, it is my goal to not be like the topic's author and argue against those who actually know there stuff. Since I seem to run across you a lot, please tell me when I am repeating the author's mistake. Thanks for being so patient with me

EDIT: As to the whole ‘‘giving up’’ thing, I am quite young (16) and though this makes me especially prone to the urge to give up, I believe it allows me to have time to get it right. I guess I all I can do is wait and work at it!

Yep. Everyone has to start somewhere.

Efficient networking tends to be so application specific in the end that it’s hard to put together some good examples (as illustrated by that thread). The major approaches tend to vary widely depending on the lower level requirements of the actual game. (For example, many RPGs wouldn’t need real time networking at all since whether the arrow or sword hits or not is ultimately based on a dice roll.)

As for “running across me a lot”, on this particular topic it’s a side effect of having written the current SpiderMonkey implementation. :slight_smile:

1 Like
As for “running across me a lot”, on this particular topic it’s a side effect of having written the current SpiderMonkey implementation. :)
Well....now I know what the ''developer'' title means...

And thanks for all the help, you two! Now time to figure out why the monkeyzone project isn’t checking out correctly anymore…

EDIT: On a side note, I think I found the author of the topic mentioned on linked in and it says he is proficient in Java. I wonder if that means he actually succeeded.