Hello,

i would like make my avatar turn when i turn camera but only on the vertical axis… I would like apply this rotation on the parent node of the avatar Spacial. How can i rotate this node from rotation of the cam but only keeping the rotation on the Y axis ? I tryed a lot of things with quaternion and matrix3f but nothing…

this rotation method is called from analog function like for the cam.

thanks…

@rify said:
I tryed a lot of things with quaternion and matrix3f but nothing..

Like screaming at them and begging?

https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:math_for_dummies

Game programming (especially 3D game programming) might be too hard for you at this stage of your learning curve.

That you have theoretical knowledge is fine, but as long as we don’t see what you’re doing, we can’t tell you what it is you’re doing wrong.

In short, we need the rotation code you’re using. And please, do use the java tag above when you paste your code.

1 Like
normen said:
Like screaming at them and begging?

nice guide :)

i do sometimes beg at my computer to make things work :D
but never scream at it, that would be a waste of time, everyone knows computers have no feelings ;)

cheers....
@pspeed said:
Game programming (especially 3D game programming) might be too hard for you at this stage of your learning curve.

i saw this method but i haven't floats necessary to use it..

That you have theoretical knowledge is fine, but as long as we don't see what you're doing, we can't tell you what it is you're doing wrong.

In short, we need the rotation code you're using. And please, do use the [java][/java] tag above when you paste your code.

I have the basic camera (flybyCamera), but locked on the Y axis for movement, to move only on the plan X,Z
on the other side the look is not locked, it is the default mode of the flyByCam.
I have one Spatial (my avatar) located on the cam location, but his orientation is fixed. I would like he turn to follow the look of the camera but only on the plan plan X/Z.
the rotation code that i use.. i have the cam.getDirection(); to get the direction of my cam, that one i want but with the look locked on the plan X/Z
and to test the rotation of the avatar node:
avatarNode.setLocalRotation(quaternion quat);

[java]private void avatarPositionRefresh(float value){
if((cameraType == CameraType.firstPersonMouseFree) || (cameraType == CameraType.firstPersonMouseLocked)){
avatarNode.move(avatarNode.getLocalTranslation().negate());
avatarNode.move(cam.getLocation().getX(),avatarNode.getLocalTranslation().getY(),cam.getLocation().getZ());

avatarNode.setLocalRotation(cam.getRotation());

}
}[/java]

http://i.imgur.com/ywYQA.png

we can see here that the avatar rotate forward too..
http://i.imgur.com/Drq2l.jpg

Don’t use rotations, use direction vectors, then simply eliminate the y component before normalizing to get a direction to create a quaternion… “read the doc” my ass.

@rify said:
i saw this method but i haven't floats necessary to use it..

Did you not see that one method returns the angles and the other one sets them? Like, you could get the angles from the camera rotation and then just use the one you want to set back to the object.

ok thanks it’s work with the lookAt function and cam direction