목록Game Dev/Unity (Udemy) (4)
KoreanFoodie's Study

Udemy 강좌를 들으며 내용 복습을 위해 기록하는 글입니다 유니티 #1-4 : tag 사용하기 유니티는 tag 를 이용해 게임 오브젝트를 쉽게 식별할 수 있다. 예를 들어, 플레이어가 충돌하면 점수를 올리는 코드를 짠다고 가정해 보자. private void OnCollisionEnter(Collision other) { if (other.gameObject.tag == "Player") { GetComponent().material.color = Color.red; gameObject.tag = "Hit"; } } 위 코드는 플레이어와 해당 오브젝트가 충돌을 하면 색깔을 빨간색으로 바꾸고, 현 게임 오브젝트의 태그를 Hit 으로 변경한다. 이때, 충돌한 오브젝트가 플레이어인지 아닌지 판단을 하기 위해..

Udemy 강좌를 들으며 내용 복습을 위해 기록하는 글입니다 유니티 #1-3 : Time.time 사용하기 Time.time 을 사용하면, 게임에서 얼마만큼의 시간이 흘렀는지를 체크할 수 있다. 다음 코드를 보자. public class Dropper : MonoBehaviour { [SerializeField] float DropTime = 3.0f; MeshRenderer meshRenderer; Rigidbody DropperRigidBody; void Start() { DropperRigidBody = GetComponent(); DropperRigidBody.useGravity = false; meshRenderer = GetComponent(); meshRenderer.enabled = fal..

Udemy 강좌를 들으며 내용 복습을 위해 기록하는 글입니다 유니티 #1-2 : CineMachine 사용하기 일반적인 게임들은 플레이어의 움직임에 카메라 시점이 연동되서 같이 움직인다. CineMachine 을 사용하면 해당 기능을 간단하게 구현할 수 있다. 먼저, Window -> Package Manager 로 들어가서, Packages 설정을 Unity Registry 로 바꾼다. 그 후, Cinemachine 을 검색해 설치한다. Cinemachine 에서 Virtual Camera 를 생성하고, MainCamera 에 CinemachineBrain 이라는 컴포넌트를 추가한다. 위 사진에서는 Live Camera 로 Virtual Follow Camera 가 들어가 있는데, 아까 전에 만든 Vi..

Udemy 강좌를 들으며 내용 복습을 위해 기록하는 글입니다 유니티 #1-1 : SerializeField 사용하기기 변수를 선언할 때, 다음과 같이 앞에 [SerializeField] 를 붙여주면, 에디터 내에서도 실시간으로 해당 값을 조정할 수 있다. public class Mover : MonoBehaviour { [SerializeField] float moveSpeed = 10.0f; void Update() { MovePlayer(); } void MovePlayer() { float xValue = Input.GetAxis("Horizontal"); float zValue = Input.GetAxis("Vertical"); transform.Translate(xValue * moveSpeed..