Control Rotation Dot Product

Can someone please explain why is my code working.
So I have lock on system in my game and I wanted main character (further MC) to turn in place with animation as enemy was strafing around him but I needed to know which side is MC turning to.
I discovered I can use “Mouse X” value node but in my case I’m using “Control Rotation” so mouse is not used. I tried countless times to make it work and my final solution is just as simple as this.


This function is called on tick inside a function “Face Actor” only if MC is standing still. So why does it work if it’s on tick and I’m taking the same two vectors, shouldn’t the result always be the same? But instead it works perfectly. Only assumptions I have is that Control Rotation is using “RInterp To” to rotate smoothly and MC’s camera has “Lag” turned on.
I’d appreciate the proper explanation.

We can’t really tell if your code is correct or not for the objective you described since you didn’t share the full code, but I think I get where the confusion is from this sentence of yours:

If you’re rotating the actor(s) after this calculation, their orientations do actually change and naturally where their forward & right unit vectors face change as the result, and that change reflects to the next calculation when the function’s called with the next tick.

Hope this helps :blush:

1 Like

I’m sorry but I don’t get that at all. As I understand forward and right vectors of the same actor should be 90 degrees all the time so the result also should be the same cause I don’t save forward vector from previous frame but using the current one. Also I’m doing rotation first and then the calculation part, my blueprint is too long to share but it’s basically “Start → Set Control Rotation → Calculate Rotation Direction → Apply appropriate montage → End”. I shared the “calculation” part of “Calculate Rotation Direction” node before.
There is “Set Control Rotation” part:

If you saved, then it wouldn’t change. Since you don’t save it inside a variable, when you get the forward / right vector of an actor, it gets the current one. For example, when you rotate an actor 90 degrees around z axis, it’s forward vector would now be on the +y direction (x = 0, y = 1, z = 0), and it’s right vector would be on the -x direction (x = -1, y = 0, z = 0)


Yep, those two specific unit vectors have a 90 degree angle between them. That’s not relevant though. They’re from different actors. Wait you’re not comparing the forward vectors though you’re comparing the locations. (Later Added)

You see, you’re setting the control rotation every tick, so every tick it’s rotation updates (and the direction of the character’s orientation vectors if the actor uses controller desired rotation), and the next tick the function where you get the orientation vectors is called, and they get the new, updated, current values. And the current values are used in to set the new rotation!

This latest blueprint code you provided seems to be rotating the the controller smoothly to face the enemy character. It doesn’t even have forward / right vectors in it. It gets the required rotation value to face the enemy with the Find Look at Rotation node. We take it as the target rotation. We set the current pin of the Rinterp To node to the controller which updates every tick, since we set it every tick. (New Explanation)

1 Like

Your explanation helped me to think in the way that when we moving the camera with the mouse, then the Mouse X value is changing smoothly towards zero when we stop. So it must be the same with Control Rotation when camera’s right vector is also smoothly going towards that “Forward” dot product between it and actor’s forward vector so it must why it’s not “Forward” all the time but smoothly going towards it.
Thank you for helping me, my final explanation may not be correct at all but it makes perfect sense for me so I’m happy with that for now.
Appreciate your help and have a nice day :]

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.