Placing model in front of flycam

Hello,

I need urgent help on how to place a model or part of a model in front of a flycam, like the hand and gun in the action games.

Very detailed help and code would be better.



Thank you very much

[java]

Vector3f position = cam.getWorldCoordinates(inputManager.getCursorPosition(), 0.3f);

[/java]

if i good know this code tells us world coordinates of place where is mouse in distance 0.3f from camera.

So you could try use:

[java]

Vector3f position = cam.getWorldCoordinates(new Vector2f(0,0), 1.5f);

[/java]



but maybe there is better way to do it

Thanks for the help, but I’m new at this can you please explain more how to use this position to set the player in front of cam.

Because as you can see from my simpleUpdate code that the cam is following the player’s location not the other way around, so how can I set the player to stay in front of cam ?

thanks again



@Override

public void simpleUpdate(float tpf) {



Vector3f camDir = cam.getDirection().clone().multLocal(0.6f);

Vector3f camLeft = cam.getLeft().clone().multLocal(0.4f);

walkDirection.set(0, 0, 0);

if (left) { walkDirection.addLocal(camLeft); }

if (right) { walkDirection.addLocal(camLeft.negate()); }

if (up) { walkDirection.addLocal(camDir); }

if (down) { walkDirection.addLocal(camDir.negate()); }



player.setWalkDirection(walkDirection);

cam.setLocation(player.getPhysicsLocation());



}

http://hub.jmonkeyengine.org/forums/?fs=move+with+cam

Hi Mr. normen thanks for your help, but the article is not there anymore, do you have something else about what I want because I’m kinda frustraded for that manner. Thanks again

What article? I posted a search url. This question has been asked like 10.000 times already.