camNode not colliding with a geometry called itembox1

I made a camNode which has a character control attached to it with a capsule collision shape. i am trying to get it to collide with a box shaped geometry called itembox1 with a rigidbodycontrol that has a mass of zero and is attached to itembox1. when i use camNode.collideWith(itembox1,res); the camNode never collides with the itembox1 and if i use a geometry such as another box with collideWith, the code has an error.

pre type="java"
package megaman;



import com.jme3.collision.Collidable;

import com.jme3.math.Vector3f;

import com.jme3.bullet.BulletAppState;

import com.jme3.bullet.control.RigidBodyControl;

import com.jme3.bullet.collision.shapes.;

import com.jme3.bullet.util.CollisionShapeFactory;

import com.jme3.scene.Node;

import com.jme3.bullet.control.CharacterControl;

import com.jme3.bullet.control.GhostControl;

import com.jme3.collision.CollisionResults;

import com.jme3.effect.ParticleEmitter;

import com.jme3.effect.ParticleMesh;

import com.jme3.font.BitmapText;

import com.jme3.input.KeyInput;

import com.jme3.input.controls.ActionListener;

import com.jme3.input.controls.KeyTrigger;

import com.jme3.input.controls.MouseButtonTrigger;

import com.jme3.light.AmbientLight;

import com.jme3.material.Material;

import com.jme3.material.RenderState.BlendMode;

import com.jme3.math.ColorRGBA;

import com.jme3.math.FastMath;

import com.jme3.math.Matrix3f;

import com.jme3.math.Matrix4f;

import com.jme3.math.Quaternion;

import com.jme3.math.Ray;

import com.jme3.math.Vector2f;

import com.jme3.renderer.Camera.FrustumIntersect;

import com.jme3.renderer.queue.RenderQueue.Bucket;

import com.jme3.scene.Geometry;

import com.jme3.scene.Mesh;

import com.jme3.scene.Spatial;

import com.jme3.scene.shape.Box;

import com.jme3.scene.shape.Quad;

import com.jme3.scene.shape.Sphere;

import com.jme3.system.AppSettings;

import com.jme3.texture.Texture;

import com.jme3.ui.Picture;

import com.jme3.ui.Picture;

import com.jme3.util.SkyFactory;

public class rpgGame extends SimpleApplication implements ActionListener {

    boolean left, right, up, down, _RELOAD, shoot, crouch, nextWep, imReloading = false, sendGunUp = false, goright = true, goleft = false, goup = true, godown = false, cantStrafe = false;

    CharacterControl player;

    RigidBodyControl landscape;

    BulletAppState bulletAppState;

    Vector3f walkDirection = new Vector3f();

    AudioNode shootSFX, reloadSFX;

    ParticleEmitter spark;

    int updateDelay = 0, mysboxframe = 1;

    Node camNode;

    float m16_x, m16_y, m16_z, recx = 0, recy = 0, recoil_z = 0;

    AmbientLight light;

    CapsuleCollisionShape capsule1;

    Geometry itembox1;

    Material mysteryboxm;

    Vector3f boxcollide1;

    RigidBodyControl itemc;

    Box charbox = new Box(Vector3f.ZERO, 5, 5, 5);

    Geometry charc;

    public static void main(String[] args) {

        rpgGame app = new rpgGame(); //Create a class object and start the app

        AppSettings settings = new AppSettings(true);





        app.start(); //Start the app to play the game



    public void simpleInitApp() {

        charc = new Geometry(“Character”, charbox);



        bulletAppState = new BulletAppState(); //Create the physics object

        stateManager.attach(bulletAppState); //Attach the physics object to the game

        bulletAppState.getPhysicsSpace().setGravity(new Vector3f(0f, -1f, 0f));

        light = new AmbientLight();



        camNode = new Node(“Camera Node”);

        Box box = new Box(Vector3f.ZERO, 4, 4, 4);

        Material floorTile = new Material(assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);

        floorTile.setTexture(“ColorMap”, assetManager.loadTexture(“rpg/tile1.png”));

        Material brickTile = new Material(assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);

        brickTile.setTexture(“ColorMap”, assetManager.loadTexture(“rpg/tile2.png”));

        mysteryboxm = new Material(assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);

        mysteryboxm.setTexture(“ColorMap”, assetManager.loadTexture(“rpg/item1.png”));

        Geometry floorTiles[] = new Geometry[300];

        for (int a = 0; a < floorTiles.length; a++) {

            floorTiles[a] = new Geometry("Floor Tile " + a, box);


            floorTiles[a].move(0, -4, a 


            RigidBodyControl tilec = new RigidBodyControl(0);




        itembox1 = new Geometry(“Item Box With Mushroom”, box); //This box appears above the 17th floor tile


        itembox1.move(0, 5, floorTiles[16].getLocalTranslation().z);


        itemc = new RigidBodyControl(50);




        capsule1 = new CapsuleCollisionShape(5, 5, 1);

        player = new CharacterControl(capsule1, 0.05f); //0.05f default for step size




        player.setPhysicsLocation(new Vector3f(0, 5, 0));

        bulletAppState.getPhysicsSpace().setGravity(new Vector3f(0f, -1f, 0f));




    CollisionResults res = new CollisionResults();


    public void simpleUpdate(float tpf) {

        Vector3f camDirection = cam.getDirection().clone().multLocal(0.4f); //0.6f

        Vector3f camLeft = cam.getLeft().clone().multLocal(0.2f);

        camDirection.y = 0;

        camLeft.y = 0;

        walkDirection.set(0, 0, 0);

        if (left) {



        if (right) {



        if (up) {



        if (down) {










    public void loadKeys() {

        inputManager.addMapping(“Left”, new KeyTrigger(KeyInput.KEY_A));

        inputManager.addMapping(“Right”, new KeyTrigger(KeyInput.KEY_D));

        inputManager.addMapping(“Up”, new KeyTrigger(KeyInput.KEY_W));

        inputManager.addMapping((“Down”), new KeyTrigger(KeyInput.KEY_S));

        inputManager.addMapping(“Jump”, new KeyTrigger(KeyInput.KEY_SPACE));

        inputManager.addListener(this, “Left”);

        inputManager.addListener(this, “Right”);

        inputManager.addListener(this, “Up”);

        inputManager.addListener(this, “Down”);

        inputManager.addListener(this, “Jump”);




    public void onAction(String binding, boolean value, float tpf) {

        if (binding.equals(“Left”)) {

            if (value) {

                left = true;

            } else {

                left = false;


        } else if (binding.equals(“Right”)) {

            if (value) {

                right = true;

            } else {

                right = false;


        } else if (binding.equals(“Up”)) {

            if (value) {

                up = true;

            } else {

                up = false;


        } else if (binding.equals(“Down”)) {

            if (value) {

                down = true;

            } else {

                down = false;


        } else if (binding.equals(“Jump”)) {






For physics objects collision checking implement PhysicsCollisionListener and register it on PhysicsSpace instead. Just use CollisionResults for non-physics objects.

im having a bit of trouble understanding the tutorial on physics listeners.Do i have to make another class just for a physics control? Im really confused.

No, just implement a PhysicsCollisionListener and register it on PhysicsSpace. You can create yourself PhysicsCollisionListenerImpl class that implements the PhysicsCollisionListener, and register it on PhysicsSpace by:


physicsSpace.addCollisionListener(new MyPhysicsCollisionListenerImpl());


Edit: At “collision()” overriden method you can check the collisions between your physics objects.

so in the other class, i would have the collision() method or what else would it exactly have in it?

EDIT: I got it to work, thanks for the help! :smiley: