Keeping an object in front of a camera

Hi,



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,

Akonkagva

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.

https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:advanced:making_the_camera_follow_a_character



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.

https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:advanced:multiple_camera_views

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

See my thread here as well:



http://hub.jmonkeyengine.org/groups/general/forum/topic/moving-3d-objects-to-a-location-on-the-screen/

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.