Some Questions Building FPS Game

Hi,

Recently I have been attempting to write a first person shooter game but recently I have run into some bugs that I have no Idea how to fix:

How do I make a ParticleEmmiter Quickly Burst then remove itself from the rootNode?

How do I create Spatials in other classes besides your main class?

What is the simplest way to display a Spatial on the GuiNode without having it look weird?
(I’ve tried this before with the help of another user, but I didn’t know how to use Nifty properly)

How to attach a billboarded image to rootNode?

I would be very grateful if any of you guys could provide me with answers.
Please Pardon My Noobiness. Thank You.

How do I make a ParticleEmmiter Quickly Burst then remove itself from the rootNode?

I don’t know about the burst by heart, but if you check it’s documentation, there might be some “time” constraint.
As for the removable, that depends on your approach, the Pro way would be adding a CustomControl to it. That leads to auto-removal in just the right time. Example:

private float removal_delay = 3000f; // Or set it dynamically using some constructors

public void update(float tpf)
{
   if (removal_delay > 0f)
       removal_delay -= tpf; 
  else
       rootNode.removeChild(this); // Don't know the exact call, might be this.getNode() or something
}

And you are done with that.

What do you mean with “create Spatials in other classes”?
You can always do:

Spatial s = app.getAssetManager().loadModel("Models/Monkey.j3o");

For that, you need to have the “app” reference, which you should get in each AppStates initializer.

You could use something like the following in your MainApplication but it’s not the proper way to do it and manipulating the nodes (from outside any of those update methods) will lead to a crash.

public MyApplication extends SimpleApplication
{
    public static MyApplication ref;

    public MyApplication()
    {
        ...
        ref = this;
    }
 }

It is highly discouraged to do so, try to understand jMe’s way of handling things.

Now to your GuiProblem: It seems like you have a 3D-Model? Are you sure that you want that to be part of the gui? (Which is mostly 2D Images). I don’t know if Nifty can handle 3D Models properly but in general it looks like the following problems:

a) You did not apply rotation in blender (CTRL+A when the model is selected). This will recalculate the triangles. If you don’t apply, it’s only blender which rotates and not the whole model.
b) You messed up exporting/importing. Use the “.blend” Model Importer over the OGRE .xml Exporter.

And what do you mean with “billboarded image”? (Sry, I’m not native :P)
In general you could use a flat cube Geometry and assign it a Texture, if you want to have 2D Images in the rootNode.
On the other hand, I’d do that all in Blender as kind of Level Editor

Thanks this will really Help :smile:

‘Quickly burst’ is just particleEmitter.emitAll()

You should also do all of the tutorials if you haven’t already. It will save you a lot of time.

Some Java tutorials might also be useful since you seem a little new to that also. The “How do I create a spatial from outside my main class?” is really more of a Java question than a JME one.

Even If i rotate it, it will still appear on the flat on the guiNode.