Integer expected when creating box

Basically what my code does is, when the user presses the left mouse button, it should create a box at the camera’s current location and then gives it a linear velocity to send it flying. The problem im having is, when run the program and click a couple of times, it comes up with an error saying, integer expected.



The code does create multiple boxes when the user holds down the mouse button, but I’m really not sure what line the error is on, because the console didn’t say any line numbers at all. Any help is appreciated, thanks.

Sorry but theres really no way to debug this from afar with so few info and the problem being in your own code… I don’t really believe you don’t get a proper stack trace… If thats the case you probably output that error yourself somewhere (maybe some try-catch). Where do you read the “integer expected” error?

Here’s the stack trace:



SEVERE Application 9:35:55 AM Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]

java.lang.IllegalArgumentException: Expected a Int value!

at com.jme3.shader.Uniform.setValue(Uniform.java:268)

at com.jme3.material.Technique.updateUniformParam(Technique.java:158)

at com.jme3.material.MatParam.apply(MatParam.java:224)

at com.jme3.material.Material.render(Material.java:846)

at com.jme3.renderer.RenderManager.renderGeometry(RenderManager.java:428)

at com.jme3.renderer.queue.RenderQueue.renderGeometryList(RenderQueue.java:174)

at com.jme3.renderer.queue.RenderQueue.renderQueue(RenderQueue.java:225)

at com.jme3.renderer.RenderManager.renderViewPortQueues(RenderManager.java:569)

at com.jme3.renderer.RenderManager.flushQueue(RenderManager.java:549)

at com.jme3.renderer.RenderManager.renderViewPort(RenderManager.java:715)

at com.jme3.renderer.RenderManager.render(RenderManager.java:738)

at com.jme3.app.SimpleApplication.update(SimpleApplication.java:253)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:137)

at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:161)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:205)

at java.lang.Thread.run(Thread.java:662)

May 28, 2011 9:35:55 AM com.jme3.app.Application handleError

SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]

java.lang.IllegalArgumentException: Expected a Int value!

at com.jme3.shader.Uniform.setValue(Uniform.java:268)

at com.jme3.material.Technique.updateUniformParam(Technique.java:158)

at com.jme3.material.MatParam.apply(MatParam.java:224)

at com.jme3.material.Material.render(Material.java:846)

at com.jme3.renderer.RenderManager.renderGeometry(RenderManager.java:428)

at com.jme3.renderer.queue.RenderQueue.renderGeometryList(RenderQueue.java:174)

at com.jme3.renderer.queue.RenderQueue.renderQueue(RenderQueue.java:225)

at com.jme3.renderer.RenderManager.renderViewPortQueues(RenderManager.java:569)

at com.jme3.renderer.RenderManager.flushQueue(RenderManager.java:549)

at com.jme3.renderer.RenderManager.renderViewPort(RenderManager.java:715)

at com.jme3.renderer.RenderManager.render(RenderManager.java:738)

at com.jme3.app.SimpleApplication.update(SimpleApplication.java:253)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:137)

at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:161)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:205)

at java.lang.Thread.run(Thread.java:662)



and here’s the code:



public void createBall(){

tinyBall = new Sphere(5, 5, 5, true, false);

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

tbt.setColor(“ColorMap”, ColorRGBA.Red);

ball_geo = new Geometry(“ball”, tinyBall);

ball_geo.setMaterial(tbt);

}



public void simpleUpdate(){

if (click) {

createBall();

ball_geo.setLocalTranslation(cam.getLocation());

ball_phy = new RigidBodyControl(1f);

ball_geo.addControl(ball_phy);

bulletAppState.getPhysicsSpace().add(ball_phy);

ball_phy.setLinearVelocity(cam.getDirection().mult(25));

}

}

Thanks Normen, I figured it out! :smiley:

I’m having another problem. whenever i create the ball by clicking, it creates it at exactly the camera’s position, so i can’t see the ball in front me. I need the ball to appear in front of the camera so that the player can see it.

https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:math_for_dummies