# Finding the character-to-character rotation relative to its forward vector #4-27

Hi!

I have a little problem finding the right value of the character rotation relative to its forward vector.

There is an AI that looks in front of itself and there is a player.
I need to find the value of how much AI should turn to face player in float.

Like if player behind AI it something about: minus 180.
If in the front is 180 (or 0).

The forward vector of the player does not matter.

“Find look at rotation” shows the value between two actors, but does not take into account the ForwardVector of the AI actor.

I’m pretty sure FindLookAt will always set the forward vector to face the required actor.

Is that not the case?

“Find look at rotation” shows the value between two actors, but does not take into account the ForwardVector of the AI actor.

You need a `dot product` of their forward vectors. This will produce a -1 to 1 range. Where anything above 0 is in front of the A vector:

This can be converted to degrees via `ACOSd`. You could derive a rotator from that.

Alternatively you could delta rotators:

It seems thats almost what i needed!

The only problem is, it takes into account the ForwardVector of the player actor. In my case, I don’t need it.

Im trying to calculate rotation target to use InPlaceRotation animation. Like if needed rotation from AI forward vector to player actor in range from 0 to 100 - use A animation, if from 100 to 200 - use B Animation and etc.

Yes it is, but i dont need player forward vector, only the AI.

This should produce a 180 Yaw rotator for the AI.

Cheaper and more data:

edit: This should work, too, ofc:

I just don’t use it often.

1 Like

Amazing! This is it.
Thank you so much for your help. The question is closed.

You should be getting a sign from the last two methods for left / right. And, you can determine front / back like so: