세팅



스크립트
public class RouletteController : MonoBehaviour
{
float rotSpeed = 0;
void Update() // 0: 왼쪽 버튼, 1: 오른쪽 버튼, 2: 휠
{
if(Input.GetMouseButtonDown(0))
{ // ButtonDown: 버튼을 눌렀을 때
Debug.Log("Down");
}
if(Input.GetMouseButton(0)) // Button: 버튼을 누른 상태로 유지 중일 때
{
this.rotSpeed = 50;
}
if(Input.GetMouseButtonUp(0)) // ButtonUp: 버튼에서 손을 뗐을 때
{
Debug.Log("Up");
}
transform.Rotate(0, 0, this.rotSpeed); // Z축으로 회전
this.rotSpeed *= 0.96f; // 회전속도 감속
}
}
실행 결과

'Unity > 수업 내용' 카테고리의 다른 글
| [Unity 2020.3] Shooting Project 플레이어의 공격 오브젝트 Bullet (0) | 2021.10.14 |
|---|---|
| [Unity 2020.3] Shooting Project 플레이어의 공격 생성, 오브젝트 풀링 (0) | 2021.10.13 |
| [Unity 2020.3] Shooting Project 플레이어 이동, 패럴렉스 스크롤링 (0) | 2021.10.13 |
| [Unity 2020.3] 애니메이션 Has Exit Time (0) | 2021.10.12 |
| [Unity 2020.3] CatEscape (0) | 2021.10.11 |