캐릭터 기본 공격 영역 로직 적용
This commit is contained in:
@@ -7,7 +7,6 @@ namespace TON
|
||||
public class CharacterBase : MonoBehaviour, IDamage
|
||||
{
|
||||
|
||||
|
||||
public float currentHP;
|
||||
public float maxHP;
|
||||
public float currentSP;
|
||||
@@ -20,6 +19,7 @@ namespace TON
|
||||
|
||||
|
||||
public Transform firePoint; // 스킬 발사 위치
|
||||
public CollisionDetector attackCollider; // 기본 공격 감지를 위한 자식 오브젝트
|
||||
|
||||
public Animator animator;
|
||||
|
||||
@@ -33,6 +33,8 @@ namespace TON
|
||||
joystick = ControllerUI.Instance.joystick;
|
||||
ControllerUI.Instance.linkedCharactor = this;
|
||||
|
||||
attackCollider.EnableCollider(false); // 기본 공격 Enable 비활성화
|
||||
|
||||
Initialize();
|
||||
}
|
||||
|
||||
@@ -45,6 +47,11 @@ namespace TON
|
||||
currentSP = maxSP = playerData.mp;
|
||||
}
|
||||
|
||||
public void UpdateExpericenPoint(float point)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void FixedUpdate()
|
||||
{
|
||||
|
||||
@@ -113,25 +120,35 @@ namespace TON
|
||||
{
|
||||
// 공격 애니메이션 적용
|
||||
animator.Play("Default Attack");
|
||||
|
||||
// 공격 범위 Collider 활성화
|
||||
attackCollider.EnableCollider(true);
|
||||
|
||||
// 일정 시간 후 Collider 다시 비활성화 (예: 0.5초 후)
|
||||
Invoke("DisableAttackCollider", 0.5f);
|
||||
}
|
||||
|
||||
private void DisableAttackCollider()
|
||||
{
|
||||
attackCollider.EnableCollider(false);
|
||||
}
|
||||
|
||||
public void SkillAttack(string skillName)
|
||||
{
|
||||
animator.Play("Skill Attack");
|
||||
|
||||
// 총알 생성
|
||||
// 스킬 생성
|
||||
GameObject skill = ObjectPoolManager.Instance.GetEffect(skillName);
|
||||
|
||||
// skill.transform.SetParent(firePoint);
|
||||
skill.transform.SetPositionAndRotation(firePoint.position, firePoint.rotation);
|
||||
|
||||
|
||||
// 🔥 총알 방향 반전
|
||||
// 🔥 스킬 방향 반전
|
||||
var bulletScale = skill.transform.localScale;
|
||||
bulletScale.x = Mathf.Abs(bulletScale.x) * lastDirection;
|
||||
skill.transform.localScale = bulletScale;
|
||||
|
||||
// 총알 이동 방향 설정
|
||||
// 스킬 이동 방향 설정
|
||||
Rigidbody2D skillRb = skill.GetComponent<Rigidbody2D>();
|
||||
skillRb.velocity = new Vector2(lastDirection * 5f, 0f);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user