Get Angle between rotating camera and player actor movement vector?

I have a camera that is in a fixed position, and rotates 360 degrees to always be focused on the player actor wherever it moves.
The player actor has a 2D sprite. I would like to mirror/flip/rotate the sprite left or right, depending on weather the actor moves mostly left or mostly right relative to the camera perspective (the actor can move in any direction anywhere in the scene).

I assume the solution is to find the vector between camera and actor, and then get the angle between that vector and the actor’s movement vector.
So then for example if the angle between the two vectors is between 0-180 I flip the sprite left, otherwise right.
I do not know the blueprint functions to calculate this.

How can I calculate it and which are the right blueprint nodes for this?

Find Look At Rotation
Camera Location, Target Location

I got that far, but my question would then be how do I get the angle of the rotator and compare it to the movement angle?

I can get the movement rotator with “Find Look At Rotation”, by feeding it a 0,0,0 vector and the actor’s movement vector.

However how do I get the angle from both rotators and compare them afterwards?

(I need to compare the movement angle on the XY axis with the camera angle on the XY axis)

From the Target: Calculate Direction (GetVelocity, Get Base Rotation)
This returns the locomotion angle (-180 to 180)

Create a BP Interface and add it to the player class.
Create a function in the BPI (Get Direction). Give the event an Output… Direction (Float).

Back in the player class, double click on the Interface function.
My Blueprint (Panel) → Interfaces (tab) → Get Direction

image

Add the code.


Now in your camera actor you need to get a reference to the player. Simple Actor reference will do, no need to cast.

With that reference you simply call the BPI event on the player.

Sorry, I’m not convinced you understood what I was asking for.
I eventually found out the solution:
I calculated the player movement direction relative to it’s current angle, using Get Velocity, Get Actor Rotation and Calculate Direction

The angle will tell me weather the player moves mostly left (angle between 90 to 180 or -90 to -180) or mostly right, no matter it’s current facing direction (which is dictated by the camera direction, because the 2D actor is set to always face the camera. Which means that it returns the left or right movement relative to the camera angle).