Sim-eth-es PlayerMovementState


Trying to make my fork of sim-eth-es a 2d game (like AsteroidPanic). I’m trying to wrap my head around how the camera, rotation and thrust relates, in order to only move in the x,y-plane and only use z-axis to rotate (when turning the plane). Right now, in the PlayerMovementState, there is this:

Quaternion rot = camera.getRotation();

// Z is forward            
thrust.x = (float)(side * speed);
thrust.y = (float)(elevation * speed); 
thrust.z = (float)(forward * speed); 
session.move(rot, thrust);

I can position the camera above the spatial as such:

camera.setLocation(spatial.getWorldTranslation().add(0,0,30));  //Set camera position above spatial
camera.lookAt(spatial.getWorldTranslation(), Vector3f.UNIT_Z); //Set camera to look at the spatial

In the AsteroidPanic, there is both Velocity as well as Position, but in sim-eth-es only Position-component. What’s the reason for this?

I would think that SpatialState and PlayerMovementState is located on the client, to only have the client deal with views and controls respectively - is this understood correctly?

Kind regards,

Asteroid Panic is a single player game… so things are simpler.


In sim-eth-es, the thrust flags are sent to the server and this controls the body in the simple physics engine. The velocity and so on is managed there… but the motion model is very different than Asteroid Panic because it’s a different kind of game. In Asteroid Panic, your directional velocity is always working against your current velocity. In Sim-eth-es (and basic), the direction of your velocity is always the same direction you are facing because I feel it’s an easier way to fly in 3D.

Since you send both rotation and thrust to the server and figure out velocity there - there’s nothing stopping me from controlling this to only move the ship in the x,y plane - I should think.

I have setup sim-eth-es and basic to only move in the x,y plane with a top down view. It works fine. Just make the changes.

1 Like

Can you disclose which changes it requires?

Sure, first you need to change the camera as you know already. Then you have to set thrust to be either x or y instead of z, Then you need to disable the mouse moving the camera. Finally you need to change the keys to rotate your ship and update the rotation Quaternion to reflect that before sending it to the server. Almost all the changes required are in

It might be best if you spend some time looking at the code very carefully to figure out whats going on. I personally recommend doing a mindmap or something similiar with xmind to try and sort things out in your mind. This is mine from a old version of sim-eth-basic

I think PlayerMovementState to make sure you send good rotations. Then if you really want to be sure, the ship driver down in the physics system to make sure thrust is always applied flat. Everything else could continue to think it’s 3D.

…then obviously the camera related changes, of course. I was mostly talking about the simulation side.