using UnityEngine;
public class RouletteController : MonoBehaviour
{
void Start()
{
}
void Update()
{
if (Input.GetMouseButtonDown(0)){
this.transform.Rotate(0,0,5);
}
}
}
1-2. 실행 코드
마우스 왼쪽을 통한 클릭 한번마다 5도씩 회전한다.
이때 움직일때 속도의 감쇠를 통해
클릭하면 돌아가는 속도가 빨라졌다가 점점 멈추게 만들어 보자.
using UnityEngine;
public class RouletteController : MonoBehaviour
{
[SerializeField]
private float maxSpeed = 10;
[SerializeField] private float attenuation = 0.96f;
private float speed = 0;
void Start()
{
}
void Update()
{
if (Input.GetMouseButtonDown(0)){
speed = maxSpeed;
}
this.transform.Rotate(0, 0, speed*=attenuation);
}
}
2-2. 실행 코드
반응형
'산대특 > 게임 클라이언트 프로그래밍' 카테고리의 다른 글
[CatEscape] CatEscape 만들기 (0) | 2024.01.29 |
---|---|
[Shuriken Swipe] 수리검 이동 및 회전 + 도착 지점 계산하기 (0) | 2024.01.27 |
[Chapter4] Swipe Car 만들기 (0) | 2024.01.26 |
GetMouseButton과 GetMouseButtonDown의 차이점 (0) | 2024.01.26 |
방향 벡터 눈으로 확인하기 (0) | 2024.01.25 |