GetAxis
움직이는 동작을 구현할 때, 사용
Input.GetAxis
키보드와 조이스틱 입력값에 대해서 -1에서 1까지의 값을 가짐
수평(좌우) 입력
Input.GetAxis("Vertical")
Input.GetAxis("Mouse X")
수직(상하) 입력
Input.GetAxis("Horizontal")
Input.GetAxis("Mouse Y")
Input.GetAxisRaw
키보드와 조이스틱 입력값에 대해서 -1, 0, 1의 값을 가짐
수평(좌우) 입력
Input.GetAxisRaw("Vertical")
Input.GetAxisRaw ("Mouse X")
수직(상하) 입력
Input.GetAxisRaw("Horizontal")
Input.GetAxisRaw("Mouse Y")
GetButton
무기를 쏘는 것과 같은 액션 트리거 이벤트를 구현하는 경우에만 사용
Input.GetButton("ButtonName")
- "ButtonName"에 의해 식별된 가상 버튼을 누르고 있는 동안 true를 반환
- "ButtonName"은 사용자가 미리 세팅 가능
- 유니티 > Edit > Project Setting > Input에서 설정 가능
Input.GetButtonDown("ButtonName")
- "ButtonName"에 의해 식별된 가상 버튼을 누르는 프레임 동안 true를 반환 (버튼을 누르는 순간 1회)
- 유저가 키를 떼었다가 다시 누를 때까지 true를 반환하지 않음
Input.GetButtonUP("ButtonName")
- "ButtonName"에 의해 식별된 가상 버튼을 뗄 때 첫 번째 프레임에서 true를 반환
GetKey
Input.GetKey("Name")
- "Name"에 의해 식별된 키를 누르고 있는 동안 true를 반환 (GetButton와 동일)
- "Name" 대신 KeyCode 사용 가능
- ex) Input.GetKey("up"); = Input.GetKey(KeyCode.UpArrow);
Input.GetKeyDown("Name")
- "Name"에 의해 식별된 키를 누르는 프레임 동안 true를 반환 (GetButtonDown과 동일)
- "Name" 대신 KeyCode 사용 가능
- ex) Input.GetKeyDown("space"); = Input.GetKeyDown(KeyCode.Space);
Input.GetKeyUp("Name")
- "Name"으로 식별된 가상 버튼을 뗄 때 첫 번째 프레임에서 true를 반환 (GetButtonUp과 동일)
- Name" 대신 KeyCode 사용 가능
- ex) Input.GetKeyUp("space"); = Input.GetKeyUp(Space);
GetMouseButton
Input.GetMouseButton(int button)
마우스 버튼을 누르고 있는 동안 true를 반환 (GetButton과 동일)
- Input.GetMouseButton(0) = 마우스 왼쪽 버튼
- Input.GetMouseButton(1) = 마우스 오른쪽 버튼
- Input.GetMouseButton(2) = 마우스 중앙(휠) 버튼
Input.GetMouseButtonDown(int button)
마우스 버튼을 누른 프레임 동안 true를 반환 (GetButtonDown과 동일)
- Input.GetMouseButtonDown(0) = 마우스 왼쪽 버튼
- Input.GetMouseButtonDown(1) = 마우스 오른쪽 버튼
- Input.GetMouseButtonDown(2) = 마우스 중앙(휠) 버튼
Input.GetMouseButtonUp(int button)
마우스 버튼을 뗄 때 첫 번째 프레임에서 true를 반환 (GetButtonUp과 동일)
- Input.GetMouseButtonUp(0) = 마우스 왼쪽 버튼
- Input.GetMouseButtonUp(1) = 마우스 오른쪽 버튼
- Input.GetMouseButtonUp(2) = 마우스 중앙(휠) 버튼
'유니티' 카테고리의 다른 글
3D 오브젝트 이동 정리 (0) | 2023.12.22 |
---|---|
프로빌더(ProBuilder) (0) | 2023.12.21 |
데미지 텍스트 효과 (0) | 2023.12.21 |
카메라 진동 효과 (0) | 2023.12.21 |
칼라 변경 (0) | 2023.12.20 |