본문 바로가기

전체 글

1. 2D 프로젝트 생성 UnityHub에서 2D 선택 후 이름 입력하고 프로젝트 생성 2D 프로젝트는 Light 오브젝트를 기본적으로 생성하지 않습니다. 3D처럼 조명이 필요하지 않기 때문입니다. 마우스 우클릭 -> 2D Object -> Sprites로 스프라이트를 생성할 수 있습니다. 그럼 Scene에 다음과 같이 빈 사각형이 뜹니다. 2D에서 원근법을 보는 방법은 다음과 같습니다. 메인카메라에서 Projection을 Perspective로 설정 Orthographic : 원근법이 없는 정사영 투시 Perspective : 원근 투시 다른 스프라이트와 우선순위를 두는법 1. 스프라이트 오브젝트의 Z축 이용 2. 스프라이트 오브젝트의 Order in Layout 이용 Order in Layout : 빨강 : 2 검정 : 1 .. 더보기
Rigidbody AddForce 한계속도 정하기 velocity를 이용해 최고속도 제한 소스코드 public float movePower; public float maxVelocityX, maxVelocityZ; void limitMoveSpeed() { if (rigid.velocity.x > maxVelocityX) { rigid.velocity = new Vector3(maxVelocityX, rigid.velocity.y, rigid.velocity.z); } if (rigid.velocity.x max.. 더보기
회전, 좌우상하 움직이는 장애물 만들기 가장 우측 오브젝트부터 순서대로 이름을 적어줬습니다. 소스코드 using System.Collections; using System.Collections.Generic; using UnityEngine; public class MoveFloor : MonoBehaviour { //UD_Floor float initPositionY; float initPositionX; public float distance; public float turningPoint; //UD_Floor & LR_Floor public bool turnSwitch; public float moveSpeed; //RT_Floor public float rotateSpeed; void Awake() { if (gameObject.nam.. 더보기
델타타임은 FixedUpdate에서 사용하지 말것 FixedUpdate 함수는 고정프레임으로, 만약 델타타임을 사용할 경우 프레임을 보장받을 수 없음. 더보기
Input은 Update함수에 최적화 Input은 Update 함수에 최적화 되어있으니 Update에서 사용할 것. FixedUpdate에서 사용할 경우, 키 입력이 버벅거리는 문제 발생 더보기
23 . 게임 빌드 Build Settings -> 옵션 확인 -> Build 클릭 결과 더보기
22. 플레이어가 맵에서 낙하 시 리스폰 빈 오브젝트나 GameManager 오브젝트에 콜라이더 추가해서 크게 만들기, isTrigger 체크 스크립트에서 onTrigger 함수로 로직 작성 예) 스테이지 재시작 void OnTriggerEnter(Collider other) { if (other.gameObject.tag == "Player") { SceneManager.LoadScene(stage); } } 결과 더보기
21. UI 만들기 Canvas 생성 후 텍스트, 버튼 생성하고 Anchor로 위치잡아주기 UI 접근 코드는 GameManager 스크립트에서 작성 소스코드 using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.UI; //UI에 접근하기 위해 필요 public class GameManager : MonoBehaviour { public int totaltemCount; public int stage; public Text stageCountText; //전체 Item 개수 public Text playerCountText; // 현재 플레이어가.. 더보기