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!