Server-side projecting

Hi everyone.

I read a lot of wiki, read a lot of forum, and spent some tests in sdk. But still I need help.

I don’t need to create a network game. It has already been created and is working. I need to do the right physics, simulate the movement of the object on area and transfer the coordinates of the object to the client. The client is already working and only waiting for network packets. It’s simple task.

So, I have a java game-server. It produces all game calculations. The client and server communicate in network packets with the data.

Now I need to add physics to it. The client and server will be communicate with the x, y, z coordinates.

I don’t need a scene renderer, sounds, control. Only physics and character control to move mobs on area.

Now about the game. I have several locations. Earth 1, Earth 2… Earth 500. Each Earth is a separate independent physical space consisting of .fbx objects and HeightMap terrain.

The game has only two types of creatures: a player and a mob. There will be no modeling. These are just spheres. Each sphere has its own GhostObjects for agrs.

How do I make the structure of the server part? I really don’t understand yet:

  1. Do I need SimpleAplication?
    1.1) If a SimpleAplication is needed, then each Earth is better made extends from SimpleAplication or there are other better options.

  2. For each Earth I want a separate StateManager where I will attach the nps and player, for better performance calculations update() states. How to create a separate StateManager for each Earth? Expand from AbstractAppState?

  3. I will need CharacterControl, walkDirection and getPhysicsLocation to send coord to the client. From which class is it better to expand the player and mob?

  4. In the future I want to use NavMesh, how to be with it?)

Last but not least. I need to design a server part and a copy of this in the sdk to debag, to see what the earth looks like.

Help create the skeleton of the server part, please.

What should I use? Libbulletjme, Minie, or native libs from maven.

My test looks working, but I don’t know how to expand further. Is it right way?


package com.test;

import java.nio.ByteOrder;
import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel;
import java.util.logging.Level;
import java.util.logging.Logger;

import com.jme3.bullet.BulletAppState;
import com.jme3.bullet.collision.shapes.CapsuleCollisionShape;
import com.jme3.bullet.control.CharacterControl;
import com.jme3.bullet.control.RigidBodyControl;
import com.jme3.material.Material;
import com.jme3.math.Vector3f;
import com.jme3.scene.Geometry;
import com.jme3.scene.Node;
import com.jme3.scene.shape.Box;
import com.jme3.system.JmeContext.Type;
import com.jme3.terrain.geomipmap.TerrainQuad;

public class TestApp extends SimpleApplication {

	private TerrainQuad terrain;
	Material mat_terrain;
	float[] heightmap;
	private BulletAppState bulletAppState;
	private CharacterControl character;
	Node model;
	private Vector3f walkDirection = new Vector3f(0, 0, 0);
	Vector3f destination;

	public static void main(String[] args) {
		TestApp app = new TestApp();

	public void simpleInitApp() {
		bulletAppState = new BulletAppState();

		// cutted code
		// heightmap create from stream byte array heightmapfile
		heightmap =;

		terrain = new TerrainQuad("my terrain", 65, 2049, heightmap);
		terrain.setLocalTranslation(2049, 0, 2049);
		terrain.setLocalScale(2f, 1f, 2f);
		terrain.addControl(new RigidBodyControl(0));


		CapsuleCollisionShape capsuleShape = new CapsuleCollisionShape(1.5f, 6f, 1);

		character = new CharacterControl(capsuleShape, 0.01f);
		Geometry testcub = new Geometry(null, new Box(3f, 3f, 3f));


		character.setPhysicsLocation(new Vector3f(1200, 200, 836));
		character.setGravity(new Vector3f(0, -30f, 0));

		destination = new Vector3f(1000, 0, 600).subtractLocal(character.getPhysicsLocation());

	public void simpleUpdate(float tpf) {
		float xdistance = character.getPhysicsLocation().x - 1000;
		if (xdistance < 10) {
			walkDirection.set(0, 0, 0);

Lot’s of network examples here:

…including two SimEthereal examples (one regular POJO based, the other entity-based).

Don’t get too wrapped around “separate state managers for different planets”. No real reason to even use app states on the server unless you don’t know how to manage a bullet physics space on your own.

The SimEthereal examples use SiO2’s GameSystemManager… which is like app states but better and without all of the rendering-related cruft hanging around.

Hello @BeCare, welcome to jmonkeyengine.

First, I would like to recommend starting with a single player game first to learn jme. Networked games are a very complex topic, something I have been working in for several years and still don’t have everything figured out :sweat_smile:. A server side game with clients can take a team of people years to get working correctly.

But to answer your questions:

  1. No, actually I recommend NOT having one server side.
  2. If not using a SimpleApplication then don’t use AppStates. Use something that works for your architecture.
  3. See stephengold/Minie: Integrate Bullet Physics and V-HACD into jMonkeyEngine projects. (code has New BSD license) (, and YES, it can be used without a SimpleApplication

Finally, as Paul Speed just beat me to mentioning, his component based libraries are great for doing networked games.

1 Like

but as i edited my first post
I don’t need to create a network game. It has already been created and is working. I need to do the right physics, simulate the movement of the object on area (terrain and .fbx stones, walls, etc) and transfer the coordinates of the object to the client. The client is already working and only waiting for network packets. It’s simple task. No need create a network game)))

For my game need

  1. phisics and collisions
  2. appstate to move objects on locations, and get it’s states for the moments (every 10 seconds)
  3. NavMesh in futur

jm3 is perfect solution, but i try do it right
I will be grateful for any advice

Some people think that they can take a single player game and turn it into a networked game. Eventually, it gets rewritten as a networked game.

When you get to that point, you have the advice above to go from.

1 Like

Some people think what i try create game). I already wrote that I am not going to create a game. It’s already work. The server part is running. I need to implement physics.

I have land, stones, walls, mountains, and so on. I did it in a blender. I just need to move object on this location, and get its coordinates of contact with the earth. No graphics, no animations, no sound, no device control.

Imagine that I painted a hilly area. Set the object, and send it to go from point A to point B. While the object moves on this plane, I get its collision coordinate with the ground every 10-5-1 seconds. That’s all.

Only it will be many objects (the same) in different lands. And simultaneously obtaining coordinates of all objects in all lands by id.

Does this look like creating a network game?

I guess we struggle because if you’ve already done all of the hard parts then we don’t understand why things like:

StateManager earth1 = new StateManager();
StateManager earth2 = new StateManager();

…are tricky for you.

You are also asking questions that indicate that you’ve already somehow painted yourself into a strange corner to want to do that anyway. The idea of multiple applications in an application (“Yo dawg, we heard you like applications in your application so we put applications in your applications in your applications.”) is one of the mistakes that very beginners often make… so we get a little triggered already.

I’ve provide example network apps to look at. You can take a look at the parts you want, or don’t. I’ve written several network applications but not any of them the way that you are doing it. So I’m probably not the best person to give advice to you.

That’s why I came here. I don’t say “hey dudes, I want a network game, tell me how to do it.”

I ask you to indicate the direction for a specific task.

Because I’m trying to figure out how to use jmonkey as correctly as possible, and I’m facing server-level physics for the first time. It was easier for me to write a network engine)))

it’s not so easy

And what does the error say on the little red ‘!’?

it requires application.

do not peek my post))) go to the youself swamp

If you extend BaseAppState instead of AbstractAppState then you will have easy access to Application (getApplication()) and a bunch of other useful stuff. AbstractAppState is there for legacy reasons and for folks who like to do things the hard way (when they use it on purpose).

…even still, it’s a sign that this is not really the right structure for you as hinted before.

There are some example applications that use a different mechanism for managing game systems. You can find them here:

sim-eth-basic is a fully working network example with server-side management of a simple physics engine with regular Java POJOs.

sim-eth-es is a fully working network example with server-side management of a simple physics engine with an entity-component-system.

Both manage game systems on the server which are like app states except without the 80% of rendering-specific stuff and “Application” dependencies that JME app states have.

pspeed Спасибо товарищ. i will try find answers on youre examples)