Null collision events?

    public void collision(PhysicsCollisionEvent event) {
        Object a = event.getNodeA();
        Object b = event.getNodeB();
        if (a == null) {
            System.out.println("Object A is null");
        if (b == null) {
            System.out.println("Object B is null");
        System.out.println(event.getNodeA().getName() + " colides with "
                + event.getNodeB().getName());

I put this inside my collision function because of NPE’s, the output is:

Floor colides with Mob
Object B is null
Floor colides with Mob
Object B is null
Floor colides with Mob
Floor colides with Marine
Floor colides with Marine

There is 1 floor, 1 green cube marine, 1 red randomly moving sphere mob
the only objects not named which are probably the null referance are bullets

            Sphere bul = new Sphere(16,16,0.3f);
            Geometry bullet = new Geometry("Bullet", bul);
            bullet.addControl(new GhostControl(new SphereCollisionShape(0.3f)));

They do get removed from the physics space, but it happens long after the collision (when they reach the world bounds) and even when they do get removed from physics space, the pointer to them inside the collision should stop the GC from collecting them??

What is happening?

Apparently not all your collision objects are associated with nodes. To find out what’s colliding, you might look at event.getObjectB().

Yes, thanks … its the ghost control apparently

So if u attach a RigidBodyControl (which contains the collision mesh) to a Spatial and that Spatial is involved in a collision, it returns the Spatial and not the Control
But if u attach a GhostControl (which contains the collision mesh) to a Spatial that is involved in a collision, it returns the Control and not the Spatial

why is that???
and if this is the standard, desired behavior why doesnt event.getNode() account for Controls tooo?

I believe that non-null collision objects (which might also be controls) should be always returned (via the getObjectA() and getObjectB() methods) in any case .

If getNodeA() or getNodeB() is returning null, that might indicate that the control isn’t added to any Spatial.
Or the collision object might be something other than a GhostControl or a RigidBodyControl.
Or somehow the collision object’s user object got set to something other than a Spatial.

Here’s the relevant code:
jmonkeyengine/ at master · jMonkeyEngine/jmonkeyengine · GitHub

It might be helpful to know which library you’re using (jme3-bullet or jme3-jbullet) and which version of the library.

Can you provide a simple example that illustrates the behavior you described?

Yes. Soon as you pointed out that it was the function returning null and not the event containing null I used getObjectB() and confirmed that it is a GhostControl.

Using: jme3-jbullet-3.2.1-stable.jar

As can be seen from physics debug mode in the image the Collision meshes are all there and all in the correct position and all moving correctly


  • Marine and Mob collide with Floor (expected and correct)
  • The projectile (with ghost control) does collide with Marine (the green square) when spawned at marine getLocalTranslate() (expected and correct) and doesnt collide with Marine when i spawn it outside the mesh (correct)
  • The projectile does collide with Floor (incorrect, it is parallel at y=1.0f with radius 0.3f) but its inconsistent (not every projectile, random) probably has to do with cloning the spacial, even though it gets translated before being attached (and ghost control automatically fetches spatial.localTranslation() onEnable())
  • However, the projectile NEVER collides with Mob and it is clearly intersecting (even when slowed down so there’s more ticks for collision

Marine and Mob are both RigidBodyControl(1.0f) and both move (though Marine much less) and both are colliding with the same object (at different times) yet one registers and the other doesnt.
Projectile also collides with Floor which is RigidBodyControl(0.0f) (which it shouldnt) meaning that its the SphereCollisionShape that is broken ??? (Sphere + Sphere not registering)

As for the GhostControl (for whatever reason it doesnt return the spacial instead) I just need to extend it to add public getSpatial() and i can manually change objects

Sphere on Sphere collisions when one is a GhostControl dont work

By changing the GhostControl CollisionShape to Box the collisions are registering

1 Like

This is good to know.

Would you consider switching to jme3-bullet or Minie?

I downloaded the basic package and am trying to learn jme3

Until i know what i’m doing i need whatever most closely matches the documentation, tutorials, example code, etc.

What is the difference with jme3-bullet and or minie?
How would I switch to them?? just replace the jar in the library?

If either do return the spacial from a ghost control for a collision event it might be worth it, even if it means the wiki becomes useless

1 Like

jme3-bullet is part of jMonkeyEngine and is included in the SDK. To switch, you’d replace the jme3-jbullet library with 2 libraries: jme3-bullet and jme3-bullet-native.

Minie isn’t part of jMonkeyEngine and doesn’t have a wiki yet.

i have found both in my library … bullet and jbullet
so i cant actually be sure which one i’m using, which must i remove?


Always BULLET.

With one of JBULLET

So if you have bullet and jbullet then you are using jbullet.

If you have bullet and bullet-native then you are using native bullet.

If you have all three then you are rolling the dice every time you play.

that kind of thing should be included in install instructions
and the SDK should probably be defaulted to one with the other in a separate folder for swapping

which should i use?
(all mentions of bullet in my jmonkey library (downloaded directly from here)


so i have 6, and i should have 2 (i guess android can stay?)
i’m guessing that jbullet.jar, jbullet-0.0.1.jar and jme3-jbullet-3.2.1-stable.jar needs to disappear?

When you created a project using the JME game template, which ones did it include?

…I’m not that familiar with the SDK because I don’t use it but I was pretty sure native was the default these days for the game project template.

Now, if you just added *.jar from libs to your project then yes you will have issues, I guess.

i am using intelliJ so yes, just created a library from the jars

Then you are including a bunch of stuff you don’t need.

This page may or may not be helpful to you:

I guess most developers have now switch to a modern build tool like maven or gradle (my preference) to avoid these sorts of issues.

i tried using maven to generate the library, it kept making a library and then following boot intelliJ marked it as invalid … shrug
my other maven libraries work great

it also couldnt pull the sources and javadocs with the library so something was obviously wrong

If you can’t access the javadocs for JME 3.2.1, it might be due to issue 861:
please add *-javadoc.jar files to JCentral deployment · Issue #861 · jMonkeyEngine/jmonkeyengine · GitHub