
Sword 스킬을 구현할 때 따라가기에 바빠서 수업중엔 제대로 이해하지 못했다.. 다시 여기에 정리하면서 이해했다…💻 UnityNetcodeUnity에서 멀티플레이어 게임을 개발할 때 사용하는 네트워킹 솔루션으로 로컬에서 동작하는 서버-클라이언트 구조를 쉽게 구현할 수 있게 한다NetworkManager서버와 클라이언트, 연결 관리NetworkObject네트워크에서 동기화되는 오브젝트NetworkBehaviour네트워크 동작을 담당하는 스크립트ServerRPC클라이언트 → 서버 호출 함수ClientRPC서버 → 클라이언트 호출 함수Ownership오브젝트의 주인(Owner) 개념🕹️ 실습 (Netcode)https://assetstore.unity.com/packages/essentials/start..

🕹️ 실습 (2D 횡스크롤 스테이트머신)Skillpublic class SkillManager : MonoBehaviour{ public static SkillManager Instance; public DashSkill dash { get; private set; } public CloneSkill clone { get; private set; } public SwordSkill sword { get; private set; } private void Awake() { if (Instance != null) { Destroy(Instance); } else { Inst..

🕹️ 실습 (2D 횡스크롤 스테이트머신)Attack// Entity.cs[Header("Collision Info")]public Transform attackCheck;public float attackCheckRadius;protected virtual void OnDrawGizmos(){ Gizmos.DrawWireSphere(attackCheck.position, attackCheckRadius);}public virtual void TakeDamage(){ Debug.Log($"{gameObject} gets damage");}// PlayerAnimationTriggers.csprivate void AttackTrigger(){ Collider2D[] colliders = P..

🕹️ 실습 (2D 횡스크롤 스테이트머신)Enemy StateMachine// Idle과 MoveState가 SkeletonGroundedState을 상속받음public class SkeletonGroundedState : EnemyState{ protected Skeleton enemy; protected Transform player; public SkeletonGroundedState(Enemy _enemyBase, EnemyStateMachine _stateMachine, string _animBoolName, Skeleton _enemy) : base(_enemyBase, _stateMachine, _animBoolName) { enemy = _en..

🕹️ 실습 (2D 횡스크롤 스테이트머신)Background Parallaxpublic class ParallaxBackground : MonoBehaviour{ private Camera cam; [SerializeField] private float parallaxEffect; private float xPosition; private float length; void Start() { cam = Camera.main; length = GetComponent().bounds.size.x; xPosition = transform.position.x; } void Update() { float distanc..

🕹️ 실습 (2D 횡스크롤 스테이트머신)벽 슬라이드, 벽 점프 구현public class PlayerWallSlideState : PlayerState{ public PlayerWallSlideState(Player _player, PlayerStateMachine _stateMachine, string _animBoolName) : base(_player, _stateMachine, _animBoolName) { } public override void Enter() { base.Enter(); } public override void Update() { base.Update(); if (Input.GetKe..

드디어 StateMachine을 제대로 적용해봤다. 이해하고 적용하는데 시간이 좀 걸렸지만 코드가 훨씬 깔끔해졌고 확실히 유지보수에 용이할 것 같다!💻 UnityVelocityRigidbody.velocity는 물체의 현재 속도를 나타내는 벡터이 벡터는 방향 + 속도의 크기를 함께 가지고 있다예: (1, 0, 0)이면 x축 방향으로 1 단위 속도로 움직이는 중단위는 미터/초(m/s)Rigidbody rb = GetComponent();void Update(){ float move = Input.GetAxis("Horizontal"); rb.velocity = new Vector3(move * 5f, rb.velocity.y, 0f);}주의사항Rigidbody 필수velocity는 Rigidb..
💻 Unity2D RaycastisGrounded = Physics2D.Raycast(groundCheck.position, Vector2.down, groundCheckDistance, whatIsGround);void OnDrawGizmos(){ Gizmos.DrawLine(groundCheck.position, new Vector3(groundCheck.position.x, groundCheck.position.y - groundCheckDistance));}groundCheck 위치에서 플레이어의 아래쪽(Vector2.down)으로 groundCheckDistance만큼 레이캐스트를 쏴서 땅이 있는지 확인isWallDetected = Physics2D.Raycast(wallCheck.pos..