UE1 - UT ViewRotation and rotators

  • Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

Zur

surrealistic mad cow
Jul 8, 2002
11,708
8
38
48
Here is a follow-up to one of my previous questions.

I've been trying to figure out which way a player is turning by getting the ViewRotation.Yaw.

Initially, I thought that the Yaw value was limited to 0-65536 which makes it difficult to determine which way a player is turning (left or right). This is because, as soon as the player turns through the 0/65536 spot, figuring out the way a player turned is guesswork.

However, it turns out that this 0-65536 limit is caused by casting to a rotator. This is confirmed by monitoring ViewRotation.Yaw directly or copying it directly to an int instead of saving to a rotator. It will increment or decrement "infinitely" it seems, making it very easy to figure out if a player is turning right or left.

Now, I have two questions. One is what variable type Epic used for ViewRotation and how far can a player can turn before it maxes out if ever. It can either be positive or negative which means that the variable type is signed. Another is whether the ViewRotation.Yaw value is the same offline than online. I've done some tests and it appears to be unchanged but I'd like a confirmation as well as any possible problems I might encounter using this value on a dedicated server.

P.S: ViewRotation.Pitch is, on the other hand, limited to a range.
 
Last edited:

Wormbo

Administrator
Staff member
Jun 4, 2001
5,913
36
48
Germany
www.koehler-homepage.de
All rotations in UT are expressed as rotators. (Later generations also use quaternions vor certain special cases.)
A rotator's components are int values. Only when typecasting a rotator to string (e.g. log(Rotation);) the components are normalized. As you know, a full rotation is 65536, or 0xffff in hexadecimal notation. The maximum positive int value is 0x7fffffff (2147483647 = MaxInt constant), adding 1 to that gives 0x80000000 (-2147483648). So, technically, a player could turn about 0x7fff (32767) times in one direction after spawning until the value wraps around.

However, if you use unnormalized values you may run into a problem when a player steps through a teleporter.
 

Zur

surrealistic mad cow
Jul 8, 2002
11,708
8
38
48
Thanks for the info. I made the assumption that rotators were limited in value to a single rotation and was probably using log(). It makes sense that the full capacity of int is used.

On the subject of teleporters, a trick is needed to ignore the change in viewrotation when a player is spawned. Apparently, playerpawns are automatically rotated to point the same way as a playerstart.

I don't know if there's an explicit way to determine if a player has entered a teleporter or rematerialized.