# Conversion from quaternion to angle

Well, i have 2 characters on scene, the player and the enemy and i want the enemy to rotate the enemy in the direction of the player…

I thought to get the angle of each to know how much he needs to rotate (if anyone got a better idea, another solution would be fine as well), thats why i need to know how to convert a quaternion to angle, cause the world rotation returns the quaternion of each.

Thx in advance once more ^^

Have you thought of using lookAt()?

This method is a convenience method defined in Spatial. In my game, I never have to manually determine angles between 2 entities for purposes of facing. lookAt() does it nicely.

You can't convert a quaternion into an angle because that's not what it represents. There is a toAngles() method which converts it into a set of three angles, making up the whole orientation.

I don't think that's really what you need, though. Turning towards something, you need to consider it's position not it's heading. You can calculate the angle between to lines, and the Vector3f class has a method to do just that: angleBetween().  To turn towards something, you might use the angle between your forward, and a line from you to the target. It's more complicated in full 3 dimensional movement but there's some ideas.

As mentioned, lookAt will easily give you the end result, and it might be the way to go depending on your requirements.

lookAt() worked fine, thx

And yeah, what i needed was the position, my mistake, but i would still need the angle to know how much to rotate i think.

Anyway, thank u both for the help