Dynamically Loading Model on fire action, not seeing anything

Hi, I am trying to develop a 3d space game and I have a nice looking laser model, however I have only been able to load it and see it when loading from simpleInItApp(). I need to load it from simpleUpdate() by calling the following method.

private void fireLaser() {
Node laser01 = (Node) assetManager.loadModel("/Models/laser01/laser01.j3o");
laser01.setLocalTranslation(getForward(player, 1));

But when I do this I can’t see any result when running the game a pressing fire.
Any help would be hot.

The starting slash isn’t needed in the path namem and the root node doesn’t need updateGeometricState() called. I don’t see anything wrong with the code but it you somehow had to call updateGeometricState() then something else is wrong that it’s hiding.

Where do you call fireLaser() from?

I call fireLaser() from simpleUpdate() if shoot == true. As far as I can tell updateGeometricState() has no affect on anything, if it is there or not. I am using JME3 RC2 if that helps.

You got a light attached to the rootNode? You’re not calling simpleInitApp yourself do you? It sounds like somehow your app is started wrong or in a very strange way when simpleInit and simpleUpdate behave differently, I have to agree with @pspeed. Or theres some of your own code in between that fools you.

Well here is my getforward() it returns world vector3f…

public final Vector3f getForward(Node node, float z) {
    Vector3f myForward = new Vector3f(0f, 0f, z);
    return myForward;


Should that not be paired with the setLocalTranslation()? tried (1, 1, 1) in place of my method and still didn’t see anything, but that might be covered by my ship, it wouldn’t more with my ship, would it? Is there any hidden file or setting to look in that might cause this behavior? Is there supposed to be an @Override over both simpleInIt() and simpleUpdate()? Below was basically my template.
package mygame;

import com.jme3.app.SimpleApplication;
import com.jme3.asset.TextureKey;
import com.jme3.bullet.BulletAppState;
import com.jme3.bullet.PhysicsSpace;
import com.jme3.bullet.collision.shapes.BoxCollisionShape;
import com.jme3.bullet.collision.shapes.CollisionShape;
import com.jme3.bullet.collision.shapes.SphereCollisionShape;
import com.jme3.bullet.control.RigidBodyControl;
import com.jme3.bullet.util.CollisionShapeFactory;
import com.jme3.material.Material;
import com.jme3.math.Vector2f;
import com.jme3.math.Vector3f;
import com.jme3.math.Quaternion;
import com.jme3.renderer.RenderManager;
import com.jme3.scene.Geometry;
import com.jme3.scene.Node;
import com.jme3.scene.shape.Box;
import com.jme3.texture.Texture;
import com.jme3.math.ColorRGBA;
import com.jme3.light.DirectionalLight;
import com.jme3.scene.Spatial;
import com.jme3.input.KeyInput;
import com.jme3.input.MouseInput;
import com.jme3.input.controls.ActionListener;
import com.jme3.input.controls.AnalogListener;
import com.jme3.input.controls.KeyTrigger;
import com.jme3.input.controls.MouseButtonTrigger;
import com.jme3.material.RenderState.BlendMode;
import com.jme3.scene.CameraNode;
import com.jme3.scene.control.CameraControl.ControlDirection;
import com.jme3.effect.ParticleEmitter;
import com.jme3.post.FilterPostProcessor;
import com.jme3.post.filters.BloomFilter;
import com.jme3.scene.shape.Sphere;
import java.util.ArrayList;
import java.util.Iterator;

public class Main extends SimpleApplication {
public static void main(String[] args) {
Main app = new Main();
public void simpleInitApp() {

public void simpleUpdate(float tpf) {

No, it won’t move with your ship unless it’s a child of the ship.

You’ll have to produce a simple test case to show us as it’s too hard to tell what is wrong from just what little bits are shown. I can say with some certainty that there is no difference between simpleInit() and simpleUpdate() as far as state is concerned.

I think I found something strange that might give us a clue. There is no laser model in assets,jar, but there is in my assets folder. When I call fireLaser() in SimpleInIt() I get an error. “Uncaught exception thrown in Thread [LWJGL Renderer Thread,5,main] NullPointerException “. Please also take note that when I run these two lines directly in SimpleInIt(), things work.
[java]Node laser01 = (Node) assetManager.loadModel(”/Models/laser01/laser01.j3o”);
edit: Sorry, that error doesn’t happen when I call it after I create my player. But the jar situation still holds true.
edit2: I get this message from Output when I call fireLaser from with in a different if statement inside simpleUpdate().
INFO: Child (Models/laser01/laser01-scene_node) attached to this node (Root Node)
Jan 30, 2013 11:41:42 AM com.jme3.scene.Node attachChild
But I still see nothing unless I call fireLaser() in un conditioned simpleUpdate(). Then I seem to get a limited stack of them at ether (0, 0, 0) or the ships starting point. And I do see them then. ??? :woot: ???

private void fireLaser() {
Node laser01 = (Node) assetManager.loadModel("/Models/laser01/laser01.j3o");
This code works, must be my getForward() was not the method to use. I still however can’t get things to work on mouse click

if (name.equals(“shoot”) && !keyPressed) {
shoot = true;
This works now. I originally made shoot = keyPressed which would always return false.

Marking it resolved. Just needed a good nights sleep I guess.

1 Like