Problems with PhysicsCharaceterNode


First off, I’m very new to Jme and 3D programming in general so the questions that I might post from this day on that is really stupid to some!

Second, it was a long time ago that I wrote some actual Java-code and currently I’m just hacking away to find my way back and to learn jme (jme3)

Okej, so here it goes:

What I’m trying to do is create a sort of character, npc like object to use in my world, this object should in the future contain information regarding the state of the npc, if it’s interactable, shootable, HP and so on. But for now I currently struggle giving life to this object in my 3D world.

The class is called LifeFormObject (I’ve been using some ideas from what the user tehflah posted some months ago) it extends PhysicsCharacterNode this i reconned was the best solution to create my own kind of “world object” for NPC’s, players and what not.

Then what i did was creating “sort of clone” of the “ChaseCamera?” class, called ThirdpersonCamera, as I did not spend enough time figuring out how to extend the original class I just made a copy and did the changes there.

But what happeneds is:

As i spawn my object into creation by adding it to the bulletAppState and the mainNode object I get a “sort of 0 fps freeze” for like 2 min, then the game slowly works it’s way up and I can start to move arround in the world with an FPS of arround 150 - 200.

What I have tried:

The thing that got me going on this is that when i instead of PhysicsCharacterNode uses a PhysicsNode I do not see this kind of behaviour. But when I read up on them both I understand that PhysicsCharacterNode is the best one to use for solving my needs.


The code here is copy-pasted from the tutorials and I’m currently as I said just experimenting with the API. if you trouble reading and / or understanding the code, I might do the effort of cleaning it up and commenting parts better.

I hope this is sufficient to understand my problem and maybe answer to whats going on.

Yeah, its because the system is slow during the frame you add all the objects and then tries to compute the lost time, you can change that by calling bulletAppState.setDeterministic(false); This way when your fps drops below 60fps the physics will not behave normal anymore but it will not try to compensate lost time.

Edit: call that before attaching the AppState

Okej thank you! Is this common to call that method, or should i approach this in a different way?

I dont know, people dont tell me when something works fine, only when it doesnt :stuck_out_tongue: The difference is simply what I stated, the physics steps get increased when the fps drops below the (fixed) physics calculation fps.

And actually you can call physicsSpace.setDeterministic() at any time, also when the physics space is running, so you can disable it while adding the objects and then enable it again in the next frame.

Okej! I’m reading through the JavaDoc of the current version of Jme3 in my JmonkeyPlatform, and the Physics(Space) “<- correct my self here…” class does not have a method called setDeterministic() my jME platform is latest version, according to the “update tool” in the netbeans fork.

To be extra safe o looked through BulletAppState aswell.

When i googled I found this, it’s in the history of the SVN repository:

Is the jme3 platform running on an older versions of the jbullet lib?

No, might be it was not in alpha-3 but you can update to the latest nightly, see the manual (F1). Note however that the physics changed a bit internally.

Thank you so much! :] I’ll try to linger my way further into jME now.