본문 바로가기
프로그래밍/Unity

getting object local direction?

by ILove_NS_MoKa 2018. 9. 11.
  1. using UnityEngine;
  2. using System.Collections;
  3. public class DrawSampleVecs : MonoBehaviour
  4. {
  5. void OnDrawGizmos()
  6. {
  7. Color color;
  8. color = Color.green;
  9. // local up
  10. DrawHelperAtCenter(this.transform.up, color, 2f);
  11. color.g -= 0.5f;
  12. // global up
  13. DrawHelperAtCenter(Vector3.up, color, 1f);
  14. color = Color.blue;
  15. // local forward
  16. DrawHelperAtCenter(this.transform.forward, color, 2f);
  17. color.b -= 0.5f;
  18. // global forward
  19. DrawHelperAtCenter(Vector3.forward, color, 1f);
  20. color = Color.red;
  21. // local right
  22. DrawHelperAtCenter(this.transform.right, color, 2f);
  23. color.r -= 0.5f;
  24. // global right
  25. DrawHelperAtCenter(Vector3.right, color, 1f);
  26. }
  27. private void DrawHelperAtCenter(
  28. Vector3 direction, Color color, float scale)
  29. {
  30. Gizmos.color = color;
  31. Vector3 destination = transform.position + direction * scale;
  32. Gizmos.DrawLine(transform.position, destination);
  33. }
  34. }


'프로그래밍 > Unity' 카테고리의 다른 글

3d 수학 기초  (0) 2018.10.01
체력 비율 계산  (0) 2018.09.12
가감속  (0) 2018.09.12
Velocity Addforc 차이점  (0) 2018.09.11
유니티 자습서  (0) 2018.09.03