# Always Rotate an Actor Relative to the Player's Location

I’ve been racking my brain over this for hours trying to figure it out, sadly my Linear Algebra Foo is undisciplined.

If I have Two actors.

Actor 1 is at Position (5, 5, 0), and has an Orientation of (0, -1, 0) Forward, (1, 0, 0) Right, (0, 0, 1) Up.

Actor 2 is at Position (2, 5, 0), and has an Orientation of (1, 0, 0) Forward, (0, 1, 0) Right, (0, 0, 1) Up. Actor 2 is looking directly at Actor 1.

(Forward Vector is Arow, Up Axis is Green Line and Right Axis if Purple)

I want to ALWAYS rotate Actor 1 according Actor 2’s local X Axis (Roll or forward view direction). Another part that isn’t helping Is I believe UE4 has a slightly different axis orientation than I am used to… X is Forward, Y is Right, and Z is Up. So basically if I change the Orientation of Actor 2 I want still want to Rotate Actor 1 According to Actor 2’s current orientation.

In this initial state Actor 1 rotates about it’s X Axis, so If I rotated it 90 Degrees Clock wise Actor 2’s new Orientation will be (0, 0, 1) Forward, (0, 1, 0) Right, (0, 1, 0) Up.

Now Say I move Actor 2 to Position (7, 5, 0) with the Orientation (0, -1, 0) Forward, (1, 0, 0) Right, (0, 0, 1) Up. It is still looking directly at Actor 1.

Now If I rotate about Actor 2’s forward axis Actor 1 needs to rotate about it’s Up Axis which should give it an Orientation of (1, 0, 0) Forward, (0, 0, -1) Right, and (1, 0, 0) Up.

Hopefully I’ve worked all that out properly in my head (and scratch paper) and hopefully you get what I am trying to accomplish. Thanks!