달력

62024  이전 다음

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30

'clremp'에 해당되는 글 1건

  1. 2017.12.08 유니티(unity) Mathf.Clamp(클램프) 사용법

Clamp(클램프) 사용법



  • Clamp(클램프) 란?
    • 최소 / 최대값 을 설정하여 float 값이 범위 이외의 값을 넘지 않도록 합니다.    

사용예시) rotation 범위 설정하기

float y = Input.GetAxis("ExtraHorizontal"); float x = Input.GetAxis("ExtraVertical"); y = y * speedRotate * Time.deltaTime; x = -x * speedRotate * Time.deltaTime; angle.x = Mathf.Clamp(angle.x + x, -80.0f, 0.0f); angle.y += y; transform.rotation = Quaternion.Euler(angle + transform.parent.eulerAngles);

사용예시) 로그 출력

 Debug.Log(Mathf.Clamp(10, 1, 3));



사용예시) position 범위 설정하기

transform.position = new Vector3(Mathf.Clamp(Time.time, 1.0F, 3.0F), 0, 0);


Posted by JakeGD
|