Rotator question

  • 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.

Mychaeel

New Member
Given UnrealScript's lack of a decent atan2 function, here's my suggestion:

Code:
static final operator(16) float angle (vector v1, vector v2) {

  local float DotProduct;
  
  DotProduct = v1 dot v2;
  
  if (DotProduct == 0.0)
    return Pi / 2;
  else if (DotProduct > 0.0)
    return Abs(Atan(VSize(v1 cross v2) / DotProduct));
  else
    return Abs(Atan(VSize(v1 cross v2) / DotProduct)) + Pi / 2;
  }

Use it as MyVector1 angle MyVector2. Returns values between zero and Pi.