Toggle Different PhysicsSpace for Different Maps

In my game there are different maps, each map is a game state… the first map is active and will render its physics nodes.



The problem is, when i go to a different map, the physics Nodes / physics space of the previous map is still there, added onto the new physics Nodes… It makes my player float, because the first map is mountainous and the next map is plane.



Is there a way to save/keep the physics space of a previous map and just use the physics space of the current map?



Should i just destroy the physics space of the previous map and recreate it when i go back to that map?



Thank you

I think just adding/removing all objects would be the easiest way. Theres methods to do that in PhysicsSpace.

Cheers,

Normen

What about using jBullet JME for multiplayer?

For example, there are more games (like on Battle.net), every game is its own gameState as I think (correct me if I am wrong), and all this is running on a server (with physics and without graphics of course).

How to implement that? Or, is it possible to have multiple PhysicsSpaces in different gamestates in one program running altogether? How complex is that to work? :slight_smile:

And if this is not possible, is there some alternative how to implement this in JME? :slight_smile:

You cam use multiple physics spaces, thats what the jme3 implementation of the physics was built for. As the AppState system is not really finalzed yet and its not being used by the core game types you'd have to create your own version of SimpleApplication right now to support multiple physics spaces. Only important thing is they should be started on different threads because they use some threadlocal variables. Doing it similar to the "parallel" multithreading solution should work fine, just use a bigger threadpool and tick the physics spaces like its done in SimpleBulletApplication (detached). In the end a physicsspace will be an appstate that you can simply add to your game, yes.

Cheers,

Normen

Hmmm, seems cool, except that I am still using JME2… 

Can this also be done in JME2?

InShadow said:

Hmmm, seems cool, except that I am still using JME2... 
Can this also be done in JME2?

Oops, sorry.. no it can't.. The jme2 version still uses globals for a lot of things :(

Jao, that means that I have to swap engines…  :frowning:

You could also start more servers on demand using the processbuilder