![]() news about forums links tools tutorials contact |
Rotators | |
Rotators...what the hell are they? Think angles. But instead of 360 degrees you have 65535 UU's (unreal units). Every actor has a Rotation variable that determines (gasp) what direction the actor is pointing. Heres exactly what a rotator is:
Rotators have 3 parts, Pitch (think up/down...try leaning over forwards, that would be consider pitching down), Yaw (think left/right...do a 360 spin...you just yawed), and finally Roll (think roll...er do a somersault, thats a form of roll). You can modify the angles just by changing each of the values, but you can not modify an actor's rotation directly, you must use the SetRotation(newRotation) function, as shown below.
So what did we just do? We made something pitch 32768 UU's (180 degrees), and then turn 16384 UU's (90 degrees). Make sense? Now, say you want to convert between vectors and rotators, or vice versa:
If you guessed that myVec is pointing in the direction of Rotation, you're absolutely correct. Now lets suppose we added another line:
Now myRot will point in the direction myVec was pointing, which happened to be the direction myRot was pointing...whoa, thats almost paradoxical or something. :) I hope I'm not confusing you here...
Easy stuff no? Just remember 65535 = 360 degrees, and to use SetRotation, and you'll do good. Rotators are useful for using angle based math, in many cases can be used in place of vector math to make some tasks much simpler. Thankfully Unreal already handles converting back and forth...
|