Keeping an object in front of a camera


Was working on my project everything went fine and now I am struggling with this problem:

An object always need to stay in front of the camera. Even if camera rotates, changes location or direction, the box still needs to be in front of it, how can it be done ?

Any help appreciated,


Well, it could be done a few ways, e.g. putting your object in a node that always follows the camera location and rotation and having your object translated a bit in front of the camera.

There is chaseCamera, and CameraNode. Depending on what you want.

Or if you want a gun on the screen, like in an FPS, then you want two viewports: your main scene, and the one that draws your weapon.

There are several forum topics about this and should have some code examples in them.

See my thread here as well:

Another interpretation is that he might be asking for how to make a billboard effect. There is a class in JME which does billboards.

Dunno… Maybe you want to do something like the guns displayed in shooters?

Gui Node is your friend then. Otherwise… Billboards and some translations are your friends.