Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.23 KB | None | 0 0
  1. bool ParkingDistance(Vector3 pos1, Vector3 pos2, double maxDistance) {
  2.  
  3.         double distance = Math.Sqrt((pos2.x - pos1.x) * (pos2.x - pos1.x) + (pos2.y - pos1.y) * (pos2.y - pos1.y) + (pos2.z - pos1.z) * (pos2.z - pos1.z));
  4.  
  5.         if (distance <= maxDistance) {
  6.  
  7.             return true;
  8.         } else {
  9.  
  10.             return false;
  11.         }
  12.     }
  13.  
  14.     bool CheckRotation(Quaternion quat1, Quaternion quat2, double[] checks) {
  15.  
  16.         double difference = Math.Sqrt((quat2.x - quat1.x) * (quat2.x - quat1.x) + (quat2.y - quat1.y) * (quat2.y - quat1.y) + (quat2.z - quat1.z) * (quat2.z - quat1.z) + (quat2.w - quat1.w) * (quat2.w - quat1.w));
  17.  
  18.         difference = Math.Round(difference, 1);
  19.  
  20.         if(Array.Exists(checks, element => element == difference)) {
  21.  
  22.             return true;
  23.         } else {
  24.  
  25.             return false;
  26.         }
  27.     }
  28.  
  29. void TimerCallback() {
  30.  
  31.         Vector3 playerPos = GameObject.FindWithTag("Lambo").transform.position;
  32.         Quaternion playerRotation = GameObject.FindWithTag("Lambo").transform.rotation;
  33.  
  34.         bool InRange = ParkingDistance(transform.position, playerPos, 3.5);
  35.         bool InRotation = CheckRotation(transform.rotation, playerRotation, new double[] {1.4, 1.8 });
  36.  
  37.         if (InRange && InRotation) {
  38.  
  39.             GUI.ToggleWinMsg(true);
  40.             CheckForParking = false;
  41.             HideWinMsg = true;
  42.         }
  43.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement