Its just maths really…

But vector in 3D space.

- get cam direction (vector) and projection of the vector onto the plane (new vector)
- rotate
- get cam direction (vector) and projection of the vector onto the plane (new vector) 2
- get angle
- rotate model

I did not get this way…

- translate vector 3d to simple vector
- rotate
- get new vector 3d translate to simple vector
- get angle

vector1 (z1,x1)

vector2(z2,x2)

Vmod = z1*x1 + z2*x2

V1 = sqrt(z1*z1 + x1*x1)

V2 = sqrt(z2*z2 + x2*x2)

cos = Vmod/V1*V1

cos to radians

http://javadoc.jmonkeyengine.org/com/jme3/math/Quaternion.html#fromAngles-float-float-float-

Or…

http://javadoc.jmonkeyengine.org/com/jme3/scene/Spatial.html#rotate-float-float-float-

I have varibles:

```
camRotation.getX()
camRotation.getY()
camRotation.getZ()
camRotation.getW()
camDir.getX();
camDir.getY()
camDir.getZ()
camLeft.getX()
camLeft.getY()
camLeft.getZ()
```

can i rotate model with this variables?

` characterModel.rotate(0.0f, camRotationY, 0.0f);`

Quaternion values are magic. Do not try to interpret meaning from them.

Quaternion values are magic. Do not try to interpret meaning from them.

Quaternion values are magic. Do not try to interpret meaning from them.

Quaternion values are magic. Do not try to interpret meaning from them.

Quaternion values are magic. Do not try to interpret meaning from them.

Repeat as needed.

But since you don’t know where the javadoc is… I’m not sure I want to be your google.

Method

```
/**
* Retun radian angle between two 2 vectors (get from Vector 3d)
* @param x1
* @param y1
* @param x2
* @param y2
* @return
*/
public float getRotation(float x1,float y1,float x2,float y2){
float Vmod = x1*y1 + x2*y2;
float V1 = (float) Math.sqrt(x1*x1 + y1*y1);
float V2 = (float) Math.sqrt(x2*x2 + y2*y2);
float cos = Vmod/V1*V2;
float radian = (float) (cos * Math.PI / 180);
return radian;
}
```

mySpatial =…

float moustMovedLeftRight = …

mySpatial.rotate(0, moustMovedLeftRight * turnSpeed, 0);

I need get angles for character model from camera rotation and direction.

float moustMovedLeftRight = …

angle… but witch formula

float mouseMovedLeftRight = mousePosition.x - lastMousePosition.x

I think one of two things are happening:

- you are making this WAY more complicated than it needs to be.
- you have not provided enough information.

I know for a fact that number (2) is true. I don’t know about number (1), though.

I have variables this is camera vectors.

and

camLeftOld = camLeft;

```
camRotation = new Quaternion(camRotationX, camRotationY, camRotationZ, camRotationW);
camDir = new Vector3f(camDirectionX, camDirectionY, camDirectionZ);
camLeft = new Vector3f(camLeftX, camLeftY, camLeftZ);
```

and this

characterModel.rotate(0.0f, camRotationY, 0.0f);

not mouse move

character model rotation by camera (mouse)

if i oldMouse.x - newMuse.x = number

i need angle between vectors

I think

```
float[] camAngles = camRotation.toAngles(null);
float rotationY = camAngles[1];
//localRotation.multL
characterModel.rotate(0.0f, rotationY, 0.0f);
```

We don’t know what you are trying to do or why you have to go through 20 strange steps to do it.

Maybe you are trying to reuse too much. It seems really strange to me to use camera movement to rotate your spatial when you could just hook it up directly and avoid the 20 different math steps between you and the mouse.

i need rotate model with camera left right move.

rotate variables:

- Quaternion
- angles

Work this

float[] camAngles = camRotation.toAngles(null);

```
float rotationY = camAngles[1];
float rotateCharacter = rotationYOld - rotationY;
rotationYOld = rotationY;
//Quaternion localRotation = new Quaternion(-0.173f, rotationY, -0.002364515f, 0.9830f);
//localRotation.multL
characterModel.rotate(0.0f, rotateCharacter, 0.0f);
```

But character must be rotate with camera direction

use lookAt method for this. but no clue what you are doing, to talk to you is like talking with robot. We suggest something and you make a different proposal. So I fear nobody is really able to help you, maybe a huge language barrier…

for example?

model.spatial.getLocalRotation().lookAt( destination, up );

what in destination variable and up variable?

Hey @nnpa, you are maybe thinking way to complicated.

The following is out of my head. This might be an approach how to get what you want:

```
float[] angles = new float[3];
cam.getRotation().toAngles(angles); // we get the cam angles here
angles[0] = 0; // you don't want to rotate along the x-axis, so we set it to 0
angles[2] = 0; // you don't want to rotate along the z-axis, so we set it to 0
player.setLocalRotation(player.getLocalRotation().fromAngles(angles)); // apply new player rot
```

Work good.