Difference between GetControlRotation and GetActorRotation in value range?

Hello there,

I am currently playing around with some things we learned in the unreal courses. What I am trying to achieve is a player interacting with a locker as in: player presses E button to interact with a locker, locker then opens the door, player automaticly moves into locker and rotates to look out the front door. To do that i created a BP_Locker Actor and placed an arrow component inside to setup the hiding position the player will be moved to when interacting with the locker:

Player Look Input and Movement will be disabled while the locker takes over the animation. While inside the locker, movement stays disabled. I am using a spring arm component with a camera inside my character. To interpolate the camera between its start and end rotation I wanted to use RInterpTo using GetControlRotation of my controller as starting point and GetWorldRotation of the arm component inside the locker as target rotation.

Now what surprised me is that when you call GetControlRotation on your Controller, it returns a rotator, ranging in values of its pitch, yaw and roll between 0-359. GetWorldRotation of the arm component in the locker also returns a rotator, but with values ranging from -180 until 180 degrees. Does anybody know why that is? Both have the same data type, but difference in value range.

You can see the values printed to my game in here:

For this i duplicated my locker 4 times and have each copy rotated by 90 degrees to face each direction. You can see its rotation values staying between -180 degrees and 180 degrees for all arrow components. I also created a rotating cube actor which continuously rotates around the Z axis and log its WorldRotation by using GetWorldRotation. The latter was used to see which value range the GetWorldRotation will allow, which is -180 up to 180 degrees as described above. The control rotation of my actor however has a range from 0 - 360 and no negative values. Both however, have the data type Rotator, which confuses me.

Steps to reproduce:

  • Create a new project, Blueprint Only, No starter content
  • Create a custom controller blueprint
  • Add event tick to your controller blueprint and log GetControlRotation
  • On every tick Increase the Roll of your controller by using GetControllRotation and SetControlRotation
  • In The World Settings Tab, override the default controller with your new controller class
  • Create a new Blueprint Actor, call it RotatingCube
  • In the event tick of the RotatingCube, use GetWorldRotation, increase the Roll by 0,1, and use SetWorldRotation on the cube to set its new rotation
  • Print out the RotatingCube rotation in event tick on each frame
  • (optional, but recommended) For both logs, connect the Delta of the Tick to your print string, or else it will flood your screen
  • Place the RotatingCube in the level
  • Hit play
  • Now you can observe the difference in value range for your control rotation and your rotating cube actor. The ControlRotation stays between 0 and 360, while the RotatingCube stays between -180 and 180 degrees.

Thank you in advance!

I wouldn’t know why they’re different without looking at the source code for both functions. That said, it’s easy enough to convert one to the other depending on which rotation you’re targeting.

Either add 180 or subtract 180 from the output you get. I’m 99% sure Unreal treats both 0/360 and -180/180 the same under-the-hood.

1 Like

Thanks for the reply.

I havent had much time to dig a bit. I will try to in the next days. However, my current work around is to add 360 than mod 360 to convert it to a 0 → 360 Degree range. I think adding 180 wouldnt be enough as -90 should equal 270 degree, not 90. This works just as intended:

Thanks again!

To be fair, -90 and 270 are in the exact same position on a unit circle.

yes exactly, you are right! thats why adding or subtracting 180 would not be sufficient to convert the rotator. I may have phrased that a bit confusing in my answer before im afraid

See, now I can compare and interpolate between the control rotation and the world rotation as intended when animating the movement:

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

Privacy & Terms