Komak57

DrawLookAngles

Jul 20th, 2013
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.25 KB | None | 0 0
  1.     Transform sight;
  2.     void OnDrawGizmos() {
  3.         Gizmos.DrawWireSphere(transform.position, AgroRange);
  4.         Gizmos.DrawWireSphere(transform.position, TrackRange);
  5.         if (!sight)
  6.             sight = transform.FindChild("Sight");
  7.                
  8.         Gizmos.DrawLine(sight.position, TranslatePos(sight.position, sight.eulerAngles.y+135,20, AgroRange));
  9.         Gizmos.DrawLine(sight.position, TranslatePos(sight.position, sight.eulerAngles.y+225,20, AgroRange));
  10.         Gizmos.DrawLine(sight.position, TranslatePos(sight.position, sight.eulerAngles.y+135,-20, AgroRange));
  11.         Gizmos.DrawLine(sight.position, TranslatePos(sight.position, sight.eulerAngles.y+225,-20, AgroRange));
  12.         if (targets.Count > 0)
  13.             Gizmos.DrawLine(transform.position, targets[0].position);
  14.     }
  15.    
  16.     Vector3 TranslatePos(Vector3 position, float yaw, float pitch, float dist) {
  17.         Vector3 tmp = Vector3.zero;
  18.         float t = (float)(dist * Mathf.Cos(ToRadian(pitch)));
  19.         tmp.y = (float)(dist * Mathf.Sin(ToRadian(pitch)) + position.y);
  20.  
  21.         tmp.x = (float)(t * Mathf.Sin(ToRadian(yaw)) + position.x);
  22.         //tmp.Y = (float)this.pos.Y;
  23.         tmp.z = (float)(t * Mathf.Cos(ToRadian(yaw)) + position.z);
  24.         return tmp;
  25.     }
  26.    
  27.     float ToRadian(float angle)
  28.     {
  29.         return 3.14f * angle / 180.0f;
  30.     }
Advertisement
Add Comment
Please, Sign In to add comment