4월, 2025의 게시물 표시

Unity Tip 4 : 게임 속도 조정

이미지
게임 속도(시간) 관련 세팅을 할 수 있는 방법이 있다 그리고, 스크립트에서 게임 일시 정지를 처리❓ Edit - Project Settings - Time 에서 Time Scale 값을 0.5 로 하게 되면 게임 플레이 속도가 절반 상세 설명을 보기 위해서 공식 매뉴얼을 보면 https://docs.unity3d.com/Manual/class-TimeManager.html 각 항목별 설명을 확인할 수 있다. 그리고, Time manager 를 통해서 게임플레이 중에 스크립트에서 설정하게 되면, 게임을 일시정지 하는 효과를 낼 수 있다 public class GameManager : MonoBehaviour {     void Pause () {         Time . timeScale = 0 ;     }     void Resume () {         Time . timeScale = 1 ;     } } 0 이면 정지, 1 이면 다시 시작

Day 18 - pathway - Unity Essentials - Programming Essentials (More things to try)

이미지
  Unity Essentials - Editor Essentials 읽어보면서 정리한 거 https://learn.unity.com/pathway/unity-essentials?version=6 Unity Essentials 의  네 번째 과정: Programming Essentials 에서 마지막에 나오는 More things to try 과정은 넘어가지 않고, 해본다.. Easy : Add a jump ability. Medium : Make the door open when the player approaches.  Expert : Use generative AI to add multi-camera toggling.      private Rigidbody rb ; // Reference to player's Rigidbody.     public float jumpForce = 5.0f ;     // Start is called before the first frame update     private void Start ()     {         rb = GetComponent < Rigidbody >(); // Access player's Rigidbody.     }     // Update is called once per frame     void Update ()     {         if ( Input . GetButtonDown ( "Jump" )) {             rb . AddForce ( Vector3 . up * jumpForce , ForceMode . Vel...

Day 14 ~ Day 17 - pathway - Unity Essentials - Programming Essentials

이미지
  Unity Essentials - Editor Essentials 읽어보면서 정리한 거 https://learn.unity.com/pathway/unity-essentials?version=6 Unity Essentials 의  네 번째 과정: Programming Essentials 4_LivingRoom_Programming_Scene 에서 ❗처음에 만든 Script file 명을 나중에 바꾸지 마라. 나중에 문제 일으킬 수 있다. 이름을 바꾸고 싶으면, 삭제 후 새로 만들어라가 가이드 MainCamera 를 Player GameObject 의 child 로 넣고 아래와 같이 해두면 진행 방향 뒤에서 보는 식으로 되네.. 신기.. ... position the camera to follow the player in a third-person view , which will be more immersive and intuitive. ❗연결된 스크립트의 Public 속성값을 Play 모드에서도 변경하는 경우에 바로 바로 적용이 되어서 적절한 값을 찾는데 도움이 되지만, Play 모드가 종료되면 값이 사라진다. 기억해 두어야 할 속성값이 많으면 Play 모드에서 Copy Component 해두고, 종료 후에 Paste Component 해두면 값이 그대로 적용 된다 PlayerController.cs A Rigidbody provides a physics-based way to control the movement and position of a GameObject. https://docs.unity3d.com/Manual/class-Rigidbody.html using UnityEngine ; // Controls player movement and rotation. public class PlayerController : MonoBehaviour {     public float speed = ...

Day 12 ~ Day 13 - pathway - Unity Essentials - Audio Essentials

이미지
Unity Essentials - Editor Essentials 읽어보면서 정리한 거 https://learn.unity.com/pathway/unity-essentials?version=6 Unity Essentials 의  세 번째 과정: Audio Essentials 새로 등장하는 component Audio Listener component   - acts like the player's ears (가까우면 크고 멀어지면 작고)  - Allow only one active Audio Listener in a scene (하나만 허용) Unity Essential Project 에서 Scene - 3_Kitchen_Audio_Scene 사용 5. Make it a 3D Audio Source 에 보면 2D Audio 가 기본 설정값으로 거리/방향에 상관없이 일정함 3D Audio 는 Spatial Blend  속성을 변경해주면 된다    0 (fully 2D) 부터 1 까지 (full 3D) spatialized : "공간화된" 또는 "공간적으로 배열된" 6. Add background music 에서 배경 음악을 설정하는 경우에는 Audio Source 의 Volume 을  0.1 - 0.5 로 해라 7. Add random bird sounds outside Audio Source + Play Sound at Random Intervals component 를 통해서 새 지저귐을 표현 반했네.. 남은 거

Debugging 설정하기 - Windows 11 + Unity 6.0 + Visual Studio Code

이미지
Mac + MonoDevelop-Unity 환경에서 디버깅 소개하는 내용을 보고 Windows 11 + Unity 6.0 + Visual Studio Code 에서 따라해보니 영상처럼 그냥 되지는 않고  몇 가지 체크를 해두어야 하네.. Debug.Log() 쓰는 것보다는 디버거 이용할 수 있도록 하자... Gemini 나 Google 검색으로는 뭔가 모호한 답변이 많음 (내가 문제일 수도 있지만,) 결국 공식문서가 제일 좋음 Unity Manual 에서 관련 내용 https://docs.unity3d.com/6000.0/Documentation/Manual/managed-code-debugging.html Visual Studio Code Manual 에서 관련 내용 https://code.visualstudio.com/docs/other/unity#_debugging 우선, Editor 우측 아래에 벌레 모양 아이콘을 통해서 Release <=> Debug 모드를 전환 디버그 모드에서 Run 하게 되면 아래 코드에서 브레이크 포인트가 걸리는 것을 기대하였는데, Square GameObject 가 생성시점에 특정 상황에서 Break 걸리면서 Visual Studio Code 로 화면이 전환되는..... 그냥은 안 되고, Debug 모드로 변경하고, Run 하기 전에 Visual Studio Code 에서 F5  키를 선택해서 Attach to Unity 상태를 만들어 둔다 => Press  F5  to start a debugging session. 이 상태에서 Unity Editor 에서 Run 하면 Break point 가 추가된 code 에 실행이 멈춘 상태로  Visual Studio Code 로 화면이 전환된다.. 예전부터 느끼는 거지만, Manual 을 잘 읽는 사람이 되자.. * Visual Studio 대신에 Visual Studio Code 사용하는 방법은 이전 게시물 중에.. h...

Unity Tip 3 : 효율적인 레이아웃 (Effective Layout) by Jessie Freeman

이미지
  링크드인의 러닝 코스( https://linkedin.com/learning )에  Jesse Freeman 이라는 강사가 있는데, Scene 과 Game view 에 더 많은 화면을 위해서 아래와 같이 Layout 을 구성하도록 권유 Window 메뉴에 Layouts 메뉴가 따로 존재하는 걸 보면 그만큼 많이 쓰이고 중요하다는 얘기인 듯.. * Window 메뉴 Layouts 에 가면 Default 선택할 수 있으니 편하게 바꿔도 됨요.. 1) Asset Store Window 일단 제거 2) 아래와 같이 재배치 Scene / Game view 를 가로 혹은 세로로 배치하고,  Hierarchy + Inspector 그 밑에 Project/Console view 를 배치히는 것 3) Window - Layouts - Save Layout... 으로 현재 Layout 설정을 Jesse Freeman 으로 저장 4) 다음에 JesseFreeman 선택하면 됨

나도코딩 - 유니티로 간단한 게임 만들기 (aa) 따라하기

이미지
 출처: 유니티 게임 개발 무료 강의 - 두 번째 따라하기 https://www.clien.net/service/board/lecture/18128206?po=0&sk=title&sv=%EC%9C%A0%EB%8B%88%ED%8B%B0&groupCd=&pt=0 강사 :  나도코딩 https://www.youtube.com/@nadocoding 나도코딩 - 유니티로 간단한 게임 만들기 https://www.youtube.com/watch?v=g3xKeBkGGRU 강의에서 사용한 Editor 버전이 2021.3.23f1 이고,  현재 최신 Editor 버전은  6000.0.42f1  이라서 해보면서 변경점 정리해 둠 최종 버전:  https://github.com/sgchoi5/Unity_Study_Projects/blob/main/AA.zip Unzip 후에 Unity Hub 에서 Add Project 에서 Add from repository 를 이용해서 import 차이점들 1) Project 생성   2D Core 대신에 Universal 2D Core 선택함    기존에 없던 옵션: Connect to Unity Cloud 는 끔 2) Scripts 폴더에서 Create => C# Script 는 이제 없어지고,     MonoBehaviour Script  선택하면 됨 3) Pin.cs 에서 충돌처리 코드 문제 Unity 6.0 사용시에 The name 'other' does not exist in the current context 라는 에러가 나오면, other 대신에  collision  으로 바꿔주면 된다. OnTriggerEnter2D() 의 parameter name 이other 에서 collision 으로 바뀜 4) Pin 을 Hierarchy 에서 삭제하는 내용 후에 실행해서 Pin 이 ...

Day 9 ~ Day 11 - pathway - Unity Essentials - 3D Essentials

이미지
   Unity Essentials - Editor Essentials 읽어보면서 정리한 거 https://learn.unity.com/pathway/unity-essentials?version=6 Unity Essentials 의 두 번째 과정: 3D Essentials < Add funitures to the kid's room > 4. Drag the bedroom prefab into the scene ... use your Frame, Orbit, Zoom skills to get a good view of the empty room: 다른 거 하다 왔더니, 기억이 하나도 안나... 다시 정리하면, F 키를 사용 Orbit 을 Alt (macOS: Option) 와 left-click and drag 사용 Zoom 을 scroll wheel 사용 5. Position the bedroom ah the origin 정확한 배치를 위해서... X = 0, Y = 0, Z = 0 < Make a bouncy ball > ... Scale 관련해서.. In Unity, scale is relative to real-world measurements, where 1 unit typically equals 1 meter . Ball 추가하는 내용이 있는데, 처음에는 1, 1, 1 이기 때문에 너무 크니 25 cm 로 바꾸라고 한 거 < Add a Collider to the ramp > 이번 장에 새겨 둘 말 ... a collider compoent, which is essential for physical interactions in Unity < Add a block and reset its Transform > 이번 장에 새겨 둘 말 In the Inspector window, ... Transform component and select Reset  to reset ... the ...