Hello monkeys
We are developing a labyrinth like game with certain “surreal” and “paradox” elements, which is the reason for the necessity of steadily (depending on the players movement speed up to more than a few times per second) “rebuilding” the level segement, that the player is currently located in.
To clear the scene graph a simple rootNode.detachAllChildren() does the job pretty well, but we are looking for a pendant of this function for the bulletAppState or the PhysicsSpace object, which we did not find so far.
As a workaround, we wrote our own “clearPhysicsSpace” function, which consists of the following:
[java]
app.getStateManager().detach(bulletAppState);
this.bulletAppState = new BulletAppState();
app.getStateManager().attach(bulletAppState);
bulletAppState.getPhysicsSpace().enableDebug(app.getAssetManager());
bulletAppState.getPhysicsSpace().add(controlPlayer);
[/java]
The actual “updateLevelElements” function which rebuilts the segement of the level, that is supposed to be visible, is called from within the collision function, so it may, as already stated above, happen quite often.
The problem is, that the updateLevelElements function is, for some reason, only called for a limited amount of iterations, ignoring any player movement after being called approximately 20 times or so, while the collision of the player with the objects itself is still working, as can be deduced from the fact, that one cannot “walk through walls”.
We assume, that it has something to do, with us regularly deleting and recreateing the whole bulletAppState, which is why I ask you for hints on how to “properly clear the PhysicsSpace”.
Other hints on what the cause of this mysterious behaviour may be and how to fix it, are also welcome of course
Thank you for your attention