전체 글 292

[복습] SpaceShooter2D - CollisionEnter2D[오류]

이렇게 했더니 안된다.. 왜 안되는건지 모르겠다.. OnCollisionEnter2D 함수는 물리적인 충돌을 감지하는 함수로서, 충돌이 발생하면 호출됩니다. 그러나 isTrigger가 체크되지 않은 Collider 간의 충돌은 물리적인 충돌이 아닌, 트리거(trigger) 충돌로 처리됩니다. 따라서 OnCollisionEnter2D 함수는 이러한 충돌을 감지하지 못합니다. 라고하는데 2D라서 안되는건가?

절대강좌 유니티 - 내비게이션 고급 기법, 동적장애물, 적 자연스러운 회전처리, Area Mask

NavMeshObstacle 컴포넌트 - 동적장애물 Carve = 우회해서 돌아옴 자연스러운 회전처리 Agent의 Auto Update 비활성화 RotateEnemy StoppingDistance에 거의 맞게 움직이기 Acceleration은 감속하거나 증가해서 미끄러짐 using System.Collections; using System.Collections.Generic; using System.Numerics; using UnityEngine.AI; using UnityEngine; using Vector3 = UnityEngine.Vector3; using Quaternion = UnityEngine.Quaternion; public class TestMonster : MonoBehaviour {..

유니티 심화 2023.08.29

절대강좌 유니티 - TMP_Text, 점수표시, PlayerPrefs, 오브젝트풀링

using System.Collections; using System.Collections.Generic; using UnityEngine; public class TestPlayerPrefsMain : MonoBehaviour { // Start is called before the first frame update void Start() { //PlayerPrefs.SetInt("player_lv", 1); bool hasKey = PlayerPrefs.HasKey("player_damage"); Debug.LogFormat("hasKey: {0}", hasKey); float damage0 = PlayerPrefs.GetFloat("player_damage"); Debug.LogFormat("dam..

유니티 심화 2023.08.29

[복습] SpaceShooter2D - Player, Bullet -> Main으로 옮기기, 오브젝트 풀링 기반 만들기

BulletController using System.Collections; using System.Collections.Generic; using System.Threading; using UnityEngine; public class BulletController : MonoBehaviour { [SerializeField] private float force = 3f; private GameObject targetTr; // Start is called before the first frame update void Start() { this.targetTr = this.GetComponent(); this.targetTr = GameObject.Find("Player"); this.transform..

오브젝트 풀링 - 총알, 이펙트

EffectPoolManager using System.Collections; using System.Collections.Generic; using UnityEngine; public class EffectPoolManager : MonoBehaviour { public static EffectPoolManager instance; //리스트로 이펙트 풀 생성 public List effectPool = new List(); //이펙트 프리팹 가져오기 [SerializeField] private GameObject effectPrefab; //몇개나 할지 max정하기 private int maxEffects = 10; //코루틴 방지 private Coroutine effectRoutine; priva..

유니티 심화 2023.08.28

절대강좌 유니티 - 오브젝트 풀링

사용할 때마다 Instantiate하지말고 미리 만들어놓고 쓰자 GameManager // 오브젝트 풀링 using System.Collections; using System.Collections.Generic; using System.Linq; using UnityEngine; public class GameManager : MonoBehaviour { //public Transform[] points; [SerializeField] private GameObject monsterPrefab; //몬스터 생성 시간 private float createTime = 3.0f; public List points = new List(); //게임 오버 private bool isGameOver = false;..

유니티 심화 2023.08.28

절대강좌 유니티 - 싱글톤, Invoke, CancelInvoke, DontDestroyonLoad

GameManager.p498 using System.Collections; using System.Collections.Generic; using UnityEngine; public class GameManager : MonoBehaviour { public Transform[] points; //public List points = new List(); private void Reset() { Debug.Log("Reset"); } // Start is called before the first frame update void Start() { Transform spawnPointGroup = GameObject.Find("SpawnPointGroup")?.transform; Debug.LogForm..

유니티 심화 2023.08.28