Move on any surface

I recently tried out Geometry Wars3 and I like those 3D map where you can navigate only in 2D. I wonder how this could be achieved. I mean I could do it with ray cast the ground and calculate the “stay on ground” somehow. But then it is bound to visual things and not possible if you have a game server. for a sphere it might be possible with pure math (quaternions).

Did somebody ever do something similar and can share his experience with me? How could I do this without depending on visual stuff?

I never did any stuff like this on server, but I can imagine how.

On the server side we need a part of the map’s mesh, it should be the place within reach on the surface. We can call it Navigation Mesh.

We need no materials, no textures, only the mesh. When moving on the surface, it means we have a start point and a target point on the mesh, then we need to calculate the path between two points.

This is just what the Recast Navigation did. The jme3-ai plugin did it, too.

On client side, we use mouse picking a target point on the map, and send it to server.

Server will decide if it’s an available place within reach. If it’s available, then calculate the path and move the player.

Client will receive the transform of the player and update the visual parts, such as position\rotation\animation.

1 Like

Here I would need a more “reactive” request to the server more the WASD keys. As well not a path finding but more a stay on the same height messured to the ground. So I would need kind a navmesh thing. Are there examples with such a mesh on the server?

In this usecase you need server side physics instead of navmesh.

Still we need the mesh, with which we can create a CollisonShape on server side. Add both player and the mesh’s collision shapes to bulletPhysics engine, then waiting for user input.

When user pressed WASD key, calculate the right ‘walking direction’ and send it to server.

On server side you can set player’s walking direction, then let bulletPhysics do the left stuff. Send player’s physical location to client per frame/tick.

On the client side, we update the player’s visiul parts with when received data from server.

I believe that there must be an example in sim-eth-es. It use bulletAppState as a System, processing Direction component and update Position component. But I cant find the link by now.

I made one in my own study project. I use zay-es in this game. InputState handles the WASD keys, CollisionState do the physics.

As I know, in real online game there should be physics engine on both clients and server. Client use physics engine to make player’s movement smother, the data received from server it used for validation. If the position on client side it not equal to the position on server side, player will “blink” to the server side position. It happens a lot when the latency is too high.

On server side, the terrain mesh is usually cut into small pieces. So the player’s collision shape can only do the math work with nearby meshes, that will make multiplayer online game server runs a little faster.

Someone talks about this problem before us

1 Like

Honestly I hoped to avoid a full fledge physic engine as I have simply a space fighter which should glide on every surface like sphere or cone or … :slight_smile:
But yeah in the end it is anyway some sort of physic system (I use sim-eth-es example as my base). And in my case I also need some mesh like thing to model this. So I’ll try to find a way. Thanks so far for your helpful and detailed input.

Whether you call it “terrain” or “collision mesh”… there must be some collidable thing on the server for the “physics” to operate on… even if it’s simple physics.

I added the gravity spheres to the sim-eth examples hoping to flesh a little of the collision and force system out but never got back to it. That would have been simple sphere-based collisions, though.

Anyway, often, the collision data on the server is not at all the same as the one the client sees as a “mesh”. Sometimes it is, though.

I did a search in our forum, and found something useful.

http://www.gabrielgambetta.com/fpm1.html

https://developer.valvesoftware.com/wiki/Latency_Compensating_Methods_in_Client/Server_In-game_Protocol_Design_and_Optimization

Ok so I still have the problem of the “how” but at least I have now the direction. I guess I’ll start with a “sphere map” of my actually 2D game which just hapen to take place on a Sphere :slight_smile:
I think to move one a sphere does not need any complicated physic (I do not even need jump as space ships don’t do that :wink:) Most probably I stay with spherical maps just to keep things as simple as possible.
I wonder if somebody did something like Mario Galaxy which is similar to what I want. I think some quaternion magic’s

Thanks a lot. But to have bullet engine for what I want seems a bit overkill and it all looks complicated. Btw I use @pspeed interpolation algo from sim-eth-es which do a pretty good job so I guess having a physic on the server should do it (or at least it seems to work pretty fine with the simple physic engine I have in place). At the moment my surface is just flat so it is in my case purly 2D from the perspective of movement.

One idea I have at the moment is that when I simply define a center (0,0,0) and place the space ship for example to (0, 100, 0) and define a radius 100. Now when ever I move in the x, z plane I have to do a correction, so that the distance to the center is always the same as well I have slighlt adjust where my nose points to. Not sure, but this sounds the easiest way. I just need to make my SimplePhysicSystem be able to do the corrections. Or do I maybe overlook something? I guess the problem is that I do not stay in the x, z plane :frowning:
Btw. by now I changed the sim-eth-es in a way that I can see the ship top down in a bird view. The sphere would make the game more attractive and you also could see your enemy a bit better because of the sphereical earth like view…

I did the same in my game, but I kept it in planar 2d. I also considered adding spherical game worlds, but decided it was too advanced to dive into right away. I’ll watch your posts to keep tabs on the progress if you share it :slight_smile:

Also this may be of some help.

I plan to share :slight_smile: at least outlines of the solution if I find any good one (formulas or so). I hope you do so as well :wink:

Cool, I guess that is what I need! I’ll study that in more detail. Thanks.

Also, looking at those videos of the game, I sense something… a presence I’ve not felt since… ©

Maybe it is not the case, but all the surfaces I’ve seen there so far don’t seem to be really arbitrary, they’re regular… so it might be that the key is some smart coordinate system transform… in this case what would be passed to client is just type of that used (i.e.: “this is a cylinder map”), and, having cylinder math model in it, client builds surface and transforms coordinates accordingly to do visualization, and to process user input… thus it might be that on server all that’d be enough to store is just x, y coordinates plus transform type… my own math is too poor to say for sure, though

Edit: those additions in bold

yeah exactly also my thought, these are all regular surfaces and some smart math.
I played that geometry war and it somehow feels good, that’s why I want to try to have similar maps (maybe in the end it will just be a shpere, but that is better than nothing, further more that way I have a natural limit of the battle ground :slight_smile: )
And for top down games that transform also makes that you can look farther… somehow.

I think I start with sphere, I found something in a unity 3D forum http://answers.unity3d.com/questions/41050/how-can-i-make-movement-on-a-sphere.html maybe that is the one.

There is a similar video for this type of game.

Is there also code snipped laying around for this? looks like what I’m looking for :slight_smile:

The shapes in Geometry Wars 3 look suspiciously well suited for distance fields…
http://www.iquilezles.org/www/articles/distfunctions/distfunctions.htm

Distance fields give you the distance from an arbitrary point to the nearest object without ray casting.
Might be worth a look.

2 Likes

It took me some time to get the idea. Looks pretty simple you have one single origin and then you have a point in space and the formula gives you the distance to the surface. So you have the direction and the length, only need to adjust the facing of the ship. Cool. I will give it a try.