본문 바로가기
반응형

전체 글381

유니티 C# 업적 시스템 만들기 간단 구현 코드 작성 using System.Collections; using UnityEngine; using UnityEngine.UI; public class AchievementSystem : MonoBehaviour { [System.Serializable] public class Achievement { public string name; public string description; public bool isUnlocked; public bool showAlert; // 알람을 띄울지 여부 public void Unlock() { if (!isUnlocked) { isUnlocked = true; Debug.Log($"업적 달성: {name}"); if (showAlert) { ShowAchievem.. 2024. 2. 29.
유니티 C# 대화창 대화 시스템 간단 구현 (미연시 게임 만들기) 코드 작성 using System.Collections; using UnityEngine; using UnityEngine.UI; public class DatingSim : MonoBehaviour { public Text dialogueText; // UI 텍스트 컴포넌트 public GameObject dialogueBox; // 대화 상자 UI private string[] dialogueLines; // 대화 문장 배열 private int currentLineIndex = 0; // 현재 대화 인덱스 void Start() { // 대화 데이터 초기화 (실제 게임에서는 파일이나 데이터베이스에서 가져올 수 있음) dialogueLines = new string[] { "안녕하세요!", "만나서 .. 2024. 2. 29.
유니티 C# 자동 전투 적 인공지능 간단 구현하기 코드 작성 using UnityEngine; public class AutoAttack : MonoBehaviour { public Transform warrior; public Transform monster; public float moveSpeed = 5f; public float attackRange = 1.5f; private bool isAttacking = false; void Update() { // 용사와 몬스터 사이의 거리 계산 float distance = Vector2.Distance(warrior.position, monster.position); // 거리가 공격 범위 이내이면 공격 if (distance 2024. 2. 29.
유니티 C# 리듬게임 만들기 Rhythm Game 예시 간단 구현 코드 작성 using System.Collections; using UnityEngine; public class RhythmGame : MonoBehaviour { public AudioClip musicClip; // 게임 음악 public float beatInterval = 1.0f; // 음악의 비트 간격 (초 단위) public KeyCode inputKey = KeyCode.Space; // 입력 받을 키 private AudioSource audioSource; private float songTime; // 현재 음악 진행 시간 private bool canInput = true; // 입력을 받을 수 있는 상태인지 여부 void Start() { audioSource = GetCompo.. 2024. 2. 29.
유니티 C# 초보자도 쉽게 따라하는 핵심 튜토리얼 자습서 간단 예시 유니티 C# 초보자도 쉽게 따라하는 핵심 튜토리얼 자습서 간단 예시 유니티로 게임을 만들 때 필수로 사용되는 기본 기능을 쉽게 배울 수 있습니다. 1. 버튼 애니메이션 2. 스크립터블 오브젝트 사용법 (최적화 기법) 3. 오브젝트 풀링 (최적화 기법) 4. 캐릭터 3D 입력 5. 타이머 6. 랜덤 7. 알림 시스템 8. 닉네임 변경 9. 사운드 매니저 10. 스킬 쿨타임 11. 거리 12. UI 스크롤 뷰 사용법 13. 캐릭터 2D 입력 14. 로컬라이징 15. 카메라 16. 자전 구매하기 유니티 초보자도 쉽게 따라할 수 있는 튜토리얼 판매 - 크몽 DevPark 전문가의 IT·프로그래밍 서비스를 만나보세요. 유니티로 게임을 만들 때 필수로 사용되는 기본 기능을 쉽게 배울 수 있습니다.Android..... 2024. 2. 29.
유니티 C# 방치형 클릭커 게임 예시 간단 구현하기 코드 작성 using System.Collections; using UnityEngine; using UnityEngine.UI; public class ClickerGame : MonoBehaviour { // UI 요소들을 연결할 변수들 public Text scoreText; // 점수를 표시하는 텍스트 public Text perSecondText; // 초당 점수 표시 텍스트 public Button clickButton; // 클릭 버튼 public Button upgradeButton; // 업그레이드 버튼 // 게임에서 사용할 변수들 private int score = 0; // 현재 점수 private int clickPower = 1; // 클릭 당 점수 private int upgra.. 2024. 2. 28.
유니티 C# 2d 플랫포머 플레이어 발판 같이 움직이는 방법 간단 구현 코드 작성 using UnityEngine; public class PlayerMovement : MonoBehaviour { private Rigidbody2D playerRb; private bool isOnMovingPlatform = false; private Transform currentPlatform; void Start() { playerRb = GetComponent(); } void Update() { // 플레이어가 움직이는 플랫폼 위에 있는지 확인 if (isOnMovingPlatform) { // 플레이어를 플랫폼과 함께 움직이도록 조정 Vector3 platformVelocity = currentPlatform.GetComponent().velocity; playerRb.velo.. 2024. 2. 26.
유니티 C# 애니메이터 사용법 간단 구현 Animator 코드 작성 using UnityEngine; public class PlayerController : MonoBehaviour { private Animator animator; void Start() { // Animator 컴포넌트 가져오기 animator = GetComponent(); } void Update() { // 사용자 입력을 감지하고 애니메이션 제어 float horizontalInput = Input.GetAxis("Horizontal"); float verticalInput = Input.GetAxis("Vertical"); // 이동 관련 애니메이션 제어 animator.SetFloat("Speed", Mathf.Abs(horizontalInput) + Mathf.Abs(verti.. 2024. 2. 26.
유니티 C# 게임 오브젝트 메세지 전달 간단 구현 SendMessage 코드 작성 using UnityEngine; public class ExampleSender : MonoBehaviour { void Start() { // GameObject에 대해 SendMessage 호출 gameObject.SendMessage("ExampleMethod", "Hello, World!", SendMessageOptions.DontRequireReceiver); } } public class ExampleReceiver : MonoBehaviour { // ExampleMethod 메소드를 가진 컴포넌트에 대한 예시 void ExampleMethod(string message) { Debug.Log(message); } } 2024. 2. 26.
유니티 C# 씬 병합하기 간단 구현 Scene Additive 코드 작성 using UnityEditor; using UnityEditor.SceneManagement; public class SceneMerger { [MenuItem("Tools/Merge Scenes")] static void MergeScenes() { // 병합할 씬의 경로를 배열에 추가 string[] scenePathsToMerge = new string[] { "Assets/Scenes/Scene1.unity", "Assets/Scenes/Scene2.unity" // 추가적으로 병합하려는 씬들의 경로를 계속 추가할 수 있습니다. }; // 새로운 씬을 만들기 (메뉴 항목에 추가될 수 있도록 새 씬을 만들 것입니다) EditorSceneManager.NewScene(NewSceneSet.. 2024. 2. 26.
유니티 C# 월드 좌표 로컬 좌표 변환 간단 구현 World Position Local Position 코드 작성 using UnityEngine; public class CoordinateConversion : MonoBehaviour { void Start() { // 예시: 월드 좌표를 로컬 좌표로 변환 Vector3 worldPosition = new Vector3(5f, 2f, 3f); // 이 스크립트가 부착된 게임 오브젝트의 Transform 가져오기 Transform myTransform = transform; // 월드 좌표를 로컬 좌표로 변환 Vector3 localPosition = myTransform.InverseTransformPoint(worldPosition); Debug.Log("World Position: " + worldPosition); Debug.Log("Local P.. 2024. 2. 26.
유니티 C# 레그돌 Ragedoll 사용법 간단 구현 코드 작성 using UnityEngine; public class RagdollController : MonoBehaviour { // 레그돌로 전환할 때 비활성화할 컴포넌트들의 배열 private Rigidbody[] rigidbodies; private Collider[] colliders; // 레그돌 상태 여부를 나타내는 변수 private bool isRagdoll = false; void Start() { // 레그돌로 전환할 때 비활성화할 컴포넌트들을 초기화 rigidbodies = GetComponentsInChildren(); colliders = GetComponentsInChildren(); // 초기에는 레그돌을 비활성화 SetRagdollEnabled(false); } void .. 2024. 2. 26.
반응형