본문 바로가기
게임개발/게임 클라이언트 프로그래밍

룰렛 만들기 GetMouseButtonDown

by pudding81 2024. 1. 28.

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class RouletteController : MonoBehaviour
{
    [SerializeField] private float maxSpeed = 2;
    [SerializeField] private float attenuation = 0.96f; //감쇠
    private float speed = 0; //시작 속도 정지

    void Update()
    {
        if (Input.GetMouseButtonDown(0)) //마우스 버튼 왼쪽을 눌렀을때
        {
          speed = maxSpeed;
        }

        this.transform.Rotate(0, 0, speed); // z축 회전 (-) 오른쪽 (+) 왼쪽
        speed *= attenuation; // 속도가 0에 수렴
        
        if(speed <0.4)
        { speed =0; } // 멈춤    
        
        
    }
}

GetMouseButton(int button)

마우스 버튼을 클릭하고 있을 때 계속 발생

 

GetMouseButtonDown(int button)

마우스 버튼을 클릭했을 때 한번 발생

 

GetMouseButtonUp(int button)

마우스 버튼을 놓았을 때 한 번 발생

 


        if (Input.GetMouseButtonDown(0))
            Debug.Log("Pressed left click.");
        
        if (Input.GetMouseButtonDown(1))
            Debug.Log("Pressed right click.");
        
        if (Input.GetMouseButtonDown(2))
            Debug.Log("Pressed middle click."); // 마우스 휠부분

 

 

'게임개발 > 게임 클라이언트 프로그래밍' 카테고리의 다른 글

표창 던지기  (1) 2024.01.28
SwipeCar  (0) 2024.01.28
Time.deltaTime  (0) 2024.01.28
벡터의 연산 : 게임오브젝트 이동  (1) 2024.01.28
벡터 연산의 이해  (0) 2024.01.25