FaceoffDebugVisualizer.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using UnityEngine;
  2. public class FaceoffDebugVisualizer : MonoBehaviour
  3. {
  4. [SerializeField] private FaceoffManager faceoffManager;
  5. [SerializeField] private bool showDebug = true;
  6. private Vector3 lastPassStart;
  7. private Vector3 lastPassEnd;
  8. private float debugTimer = 0f;
  9. void Update()
  10. {
  11. if (debugTimer > 0)
  12. {
  13. debugTimer -= Time.deltaTime;
  14. }
  15. }
  16. void OnDrawGizmos()
  17. {
  18. if (!showDebug || debugTimer <= 0) return;
  19. // Draw pass line
  20. Gizmos.color = Color.cyan;
  21. Gizmos.DrawLine(lastPassStart, lastPassEnd);
  22. Gizmos.DrawSphere(lastPassStart, 0.2f);
  23. Gizmos.DrawSphere(lastPassEnd, 0.2f);
  24. // Draw arrow
  25. Vector3 direction = (lastPassEnd - lastPassStart).normalized;
  26. Vector3 arrowPoint = lastPassStart + direction * Vector3.Distance(lastPassStart, lastPassEnd) * 0.5f;
  27. Gizmos.DrawLine(arrowPoint, arrowPoint + Quaternion.Euler(0, -30, 0) * -direction * 0.5f);
  28. Gizmos.DrawLine(arrowPoint, arrowPoint + Quaternion.Euler(0, 30, 0) * -direction * 0.5f);
  29. }
  30. public void DrawPass(Vector3 start, Vector3 end, float duration = 3f)
  31. {
  32. lastPassStart = start;
  33. lastPassEnd = end;
  34. debugTimer = duration;
  35. }
  36. }