Rotating Target with Chase Camera

Hi there,

I’m trying to figure out how to rotate my model to always face away from the chase camera, from what I understand the camera direction is a vector and a rotation is a matrix…

Seeing as my math skills aren’t so hot.

I’m unsure how to take the Camera direction and convert it to the rotation of the model.

Would there be something to do with chase camera to make this easy?

Any help would be appreciated!,%20com.jme3.math.Vector3f)

Though that presumes you mean direction in 3D space. If you only want it to match the camera direction in x,z space then it’s different.

I want to use the chase camera drag to rotate feature to make my model face opposite the camera. But only in x and z.

I dont want him to seem laying down if the camera goes up.

Right now he will travel correctly in the model direction, but he will either seem to be running sideways or backwards.

It’s a human model that I essentially want to turn as the camera turns.

Then you want something like:
float angle = cam.getRotation().toAngles(null)[1];
Quaternion rotation = new Quaternion().fromAngles(0, angle, 0);

I’m typing that from the top of my head but it’s something like that. You may want to cycle through some of the docs like the jme3 Math for Dummies link and the other links nearby in the right sidebar of this page. There are some good primers in there.

thank you, I’ll take a look.

You never think you need all that math your taught until you need it… I’ll read up on it.

Thanks for the help