long story short:
I had a Spatial with a RigidBodyControl and a GhostControl.
However, I could not correctly add the Spatial to the PhysicsSpace (using physicsSpace.add(spatial)), so I took a look at the code I found on Github:
public void add(Object obj) {
if (obj instanceof PhysicsControl) {
((PhysicsControl) obj).setPhysicsSpace(this);
} else if (obj instanceof Spatial) {
Spatial node = (Spatial) obj;
PhysicsControl control = node.getControl(PhysicsControl.class);
control.setPhysicsSpace(this);
} else if (obj instanceof PhysicsCollisionObject) {
addCollisionObject((PhysicsCollisionObject) obj);
} else if (obj instanceof PhysicsJoint) {
addJoint((PhysicsJoint) obj);
} else {
throw (new UnsupportedOperationException("Cannot add this kind of object to the physics space."));
}
}
I think it’d probably be a good idea to iterate through every Control of the Spatial and check if it’s instanceof PhysicsControl instead of only looking for one.
That’s it, should be a small change
After I was away for some time, I finally figured everything out. The pull request is now complete.
I saw that someone else edited physics space in the meantime, so there are merge conflicts.
But it shouldn’t be too much of a problem since I only modified a couple lines.