Notice
Recent Posts
Recent Comments
Link
«   2025/04   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30
Tags
more
Archives
Today
Total
관리 메뉴

8 STRENGTH

유니티 4일차. 본문

유니티

유니티 4일차.

다민 2022. 7. 21. 03:38

룰렛 게임 만들기

 

png 파일을 프로젝트에 드래그 앤 드롭으로 넣기

화면 속도 설정 game view VSync(Game view only) 설정 (모니터 갱신 속도랑 프레임을 그리는 속도를 맞추는 기능)

스마트폰 용으로 빌드 file > build setting > android > switch platform

game view free aspect 해상도 설정 (2436 * 1125)

씬 저장 file > save as ‘GameScene’

6. 이미지 배치 roullete(0, 0, 0) arrow(0, 3.2, 0)

7. 메인 카메라 > 배경 색상 블랙

8. c# 스크립트 파일 생성

 

transform : 오브젝트의 위치, 회전, 크기를 설정해주는 컴포넌트(도구)

 

더보기

RouletteControler.cs

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

public class RouletteControler : MonoBehaviour
{
    float rotspeed = 0; //룰렛의 회전 속도

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

    }

    // 한 프레임 당 한번 씩 실행되는 위치
    void Update()
    {
        //클릭을 진행하면 회전 속도를 설정해주는 코드
        //Input.GetMouseButtonDown(0)

        //조건문 if문
        //if (조건식)
        // {
        //     조건식이 만족할 때, 실행할 명령문;
        // }

        //만약에 클릭을 진행했다면, 속도를 10으로 설정하겠습니다.
        if (Input.GetMouseButtonDown(0))
        {
            rotspeed = 10;
        }

        //회전 진행하는 기능 transform.Rotate(X,Y,Z);
        transform.Rotate(0, 0, rotspeed);

        rotspeed *= 0.96f;

    }
}