본문 바로가기
Unity/수업내용

[Unity 2D / 유니티교과서] 3장 예제 Roulette

by 왹져박사 2023. 1. 30.
728x90
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class RouletteController : MonoBehaviour
{
    private float rotSpeed = 0;
    public float attenuation = 0.96f;

    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            this.rotSpeed = 10;
        }
        //오브젝트를 회전 하는 방법
        //회전은 Transform이 관리함
        this.transform.Rotate(0, 0, rotSpeed);

        Debug.Log(rotSpeed);
        this.rotSpeed *= attenuation;
        if (this.rotSpeed < 0.01f)
        {
            this.rotSpeed = 0;
        }
        
    }
}

 

 

728x90