Incorrect Collision Detecting (Collision When Ball is Nowhere Near Target)

For some reason in the game I am developing, the collisions seem to be completely incorrect. I use this code to detect the collision between the ball (player) and the pressure pad (this is in the pressure pad class):

    public void collision(PhysicsCollisionEvent event) {
        if (event.getNodeA().getName() == "Player") {
                System.out.println(this + " Collided at Node " + event.getNodeA().getName());
        if (event.getNodeB().getName() == "Player") {
                System.out.println(this + " Collided at Node " + event.getNodeB().getName());

However when I run, even though the ball is nowhere near the pressure pad, it detects a collision and prints that out. Is there anything I am missing or doing incorrectly?

I am grateful for any help :slight_smile:

Just a guess, but if you are using a GhostControl it uses the bounding box of the collision shape for collision detection

No, I am using RigidBodyControl, I hope that I am using it correctly :stuck_out_tongue:
I have done about 2 more hours of trying to figure it out to no avail. Any ideas?

Try to enable the debug shape as described here:

Maybe that will show you what is happening.

That’s what is strange, I enabled that beforehand and nothing is out of place!

I found out something interesting. When I am not touching the cubes or pressure pads the collision is not detected. I use this code to create the cubes and pressure pads for the map (maybe something is static that causes it to be called if I am touching any cube at at all?):

public Cube(PlayerBall playerBall, AssetManager assetManager, Node rootNode, Type type, BulletAppState bulletAppState, float x, float y, float z) {
this.t = type;
this.xt = x; = y;
this.zt = z;
b = new Box(1, 1, 1);
sphereGeo = new Geometry(“Shiny rock”, b);
TangentBinormalGenerator.generate(b); // for lighting effect
sphereMat = new Material(assetManager,
sphereMat.setBoolean(“UseMaterialColors”, true);
if (type == Type.Normal) {
sphereMat.setColor(“Diffuse”, ColorRGBA.White);
} else if (type == Type.Spawn) {
sphereMat.setColor(“Diffuse”, ColorRGBA.Green);
} else if (type == Type.PressurePlate) {
sphereMat.setColor(“Diffuse”, ColorRGBA.Red);
sphereMat.setColor(“Specular”, ColorRGBA.White);
sphereMat.setFloat(“Shininess”, 65f); // [0,128]
sphereGeo.setLocalTranslation(new Vector3f(xt, yt, zt));
this.playerBall = playerBall;

and this isn’t a voxel engine, just a cube based puzzler.

I’m not sure I’ve fully followed this thread…

but you do know that a collision listener is called for all collisions, right?

The fact that you’ve made your cube also a listener is perhaps misleading. I noticed in your first code you print “this” even though “this” is completely irrelevant to the collisions.

The event says that A and B collided. “this” doesn’t mean anything in that context unless you are testing to see if A == this or B == this.

Ohhhh I get it. I’m sorry, for some reason I thought that the collision was called for whatever rigidbody it implements. Somehow I deluded myself into thinking it had a rigidbody implemented as well. I’m sorry about that. What would i use to check if player and pressurepad/block have collided?