목록2023/09/19 (2)
아카이브

자동 원거리 공격 구현 Enemy 레이어 추가 후 프리팹에 지정 몬스터 스캔을 담당할 스크립트 추가 using System.Collections; using System.Collections.Generic; using UnityEngine; public class Scanner : MonoBehaviour { //범위, 레이어, 스캔 결과 배열, 가장 가까운 목표를 담을 변수 생성 public float scanRange; public LayerMask targetLayer; public RaycastHit2D[] targets; public Transform nearestTarget; void FixedUpdate() //스캔을 하기위한 로직 { //CircleCastAll: 원형의 캐스트를 쏘고 모든..

소환 레벨 적용 근접무기 구현 프리팹을 만든다 Bullet.cs using System.Collections; using System.Collections.Generic; using UnityEngine; public class Bullet : MonoBehaviour { public float damage; public int per; public void Init(float damage, int per) { this.damage = damage; this.per = per; } } 충돌로직 작성 Bullet 컴포넌트로 접근하여 데미지를 가져와 피격계산 남은 체력을 조건으로 피격과 사망 나누기 사망할 땐 SetActive 함수를 통한 비활성화 Enemy.cs using System.Collections..