I’m trying to implement a simple 2d game with physics, based on 3d.
Now I wrote a model (which deals with bulletAppState and so on), server and client.
When I’m launching server with GUI everything works OK, but when I’m launching server in headless mode (SimpleApplication::start(JmeContext.Type.Headless) and don’t attach Nodes to GUI node), sometimes collisions of my ball (dynamic) and player (kinematic) doesn’t work – it acts like there is no player; meanwhile, walls (static) works fine.
What could be wrong?
P.S.: Here is my source code: GitHub - sn-ma/PoolGame . It’s on Kotlin, and I’m using maven to build it up.
For physics, it doesn’t matter if you attach the spatial to the scene or not. But if you aren’t going to attach it to the scene then why use a spatial at all? Just use the rigid body directly.
And if your answer is “Because I look at the spatial for this or that” then recognize that nothing about the spatial will be updated to match the physics object because the spatial isn’t in a scene and thus its controls/position/etc. aren’t updated every frame.
Probably, I don’t actually need to create those spatials in the headless server case; but it’s easier to create them always – the code is shared between client and server, such as analysis of collision detection and so on.
For now I’ve updated the code on github, so, if you want to reproduce the bug, you should change the code block in file Model.kt from
What Paul says about spatials on the server is true, and whilst I’m not very proficient in kotlin i see you set and get transforms on the spatial, but when you add a physics control you must interact with the physics control transform - including reading them.
It could be that you have mixed code somewhere reading the spatial (scene graph) transform on the server as a result - which would be wrong if you didn’t add them to the scene graph on the server.