Solved: Manually call physicsSpace.update

Hello!

I can’t use the SimpleApplication class so I created a custom updater for the PhysicsSpace.
I try to manually call the update method of my physicsSpace but nothing move… What’s wrong ?

To update the physicsSpace I use :
physicsSpace.update(tpf);

I try to add a custom controller in the PhysicsSpace :
physicsSpace.add(new SimpleController());

I the controller I have the default update method where I put a simple log to know if the method is called:

@Override
public void update(float tpf) {
System.out.println(“SimpleController.update”);
}

The message is never called !
My SimpleController extends AbstractPhysicsControl. And I implemented the addPhysics method:

@Override
protected void addPhysics(PhysicsSpace space) {
space.addTickListener(this);
}

This method is called, so it’s good…
You can see that I use a trickListener too. And the methods prePhysicsTick et physicsTick are called, it’s also good

Why is my update method never called?

Can you try with adding physicsSpace.distributeEvents(); after physicsSpace.update(tpf);

Thanks for the quick response!
I tried to call distributeEvents… But it still doesn’t work :confused:

Should I manually call update ?

Note you can only add PhysicsControl or Spatial with PhysicsControl

See

My SimpleController extends AbstractPhysicsControl.
And AbstractPhysicsControl implements PhysicsControl.
So normally no problem ?

I found !!! :grinning:
It’s only the Spatial that call the update method !
(Spatial.java at line 736)

Thanks @Ali_RS

2 Likes

You’re welcome

btw, this is an example of using PhysicsSpace directly, outside of BulletAppState. You might find it helpful

The whole demo is here

1 Like

Why?

…or any RigidBody, etc… you can use JME’s bullet without ever creating a Control.

You beat me to it.