[모두의연구소]0916

ROSI·2023년 9월 16일
0

Camera의 projection 방식으로 두 가지가 있는데, perspective는 멀리 있는 게 작게 보이고 orthograpic 은 멀리 있어도 크기 그대로 보임.

perspective 카메라는 절두체 형태로 생김. 멀리 있는 것들이 가까이 있는 면으로 투영되어 보임 멀수록 작아져서 투영되는 방식.

UIcamera는 보통 직교 투영으로 씀

Main Camera, UI Camera 만들면 먼저 만들어진 Main Camera에만 우리가 만든 object들이(첫 번째 카메라에서 그린 것들) 보이는데 그걸 UI에서도 보게 하려면 해당 카메라의 Clear Flags를 Skybox(default) → Don’t Clear 로 변경 필요

Assets에서 Physical Material 생성한 다음, Bounciness 값 제공

그 다음 만들어 둔 Sphere의 Collider Material에 만든 Physical Material 넣어주면 공이 통통 튐

차가 앞으로 가게 하기 위해서는 Assets 에서 C# script 작성하고, Car에 Script 컴포넌트 & Rigidbody 컴포넌트 추가

C# script

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class basic : MonoBehaviour
{
    // Start is called before the first frame update
    Vector3 dir = Vector3.zero;
    public float moveSpeed = 10.0f;
    void Start()
    {
    }
    // Update is called once per frame
    void Update()
    {
        this.transform.position += dir * Time.deltaTime;
    }
    public void forward()
    {
        // Debug.log("forward");
        dir = this.transform.forward;
    }
    public void stop()
    {
        dir = Vector3.zero;
    }
}

만들어 둔 캔버스와 버튼들 중 Forward로 쓸 버튼 정해서 On Click() 추가하고 만든 Car 추가, basic.forward 등록

플레이 버튼 누르면 Car 앞으로 감!

profile
https://songdaegeun.github.io/ 으로 블로그이전 중입니다

0개의 댓글