유니티 엔진/Parrying Sowrd
Parrying Sword #9 : [기획][프로그래밍] 폭탄 구현 중
라구넹
2023. 2. 17. 12:11
벽을 부수는 것도 재밌겠다 싶어서 폭탄을 만들어 보았습니다.
아직 폭발 이펙트는 만들어지지 않았으며, 폭발이 플레이어나 몬스터에게 대미지를 줄 지는 아직 고민 중입니다.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DemolishingBomb : MonoBehaviour
{
Collider2D[] colliders;
Rigidbody2D rb;
private void Awake()
{
rb = GetComponent<Rigidbody2D>();
Invoke("bomb", 3.0f);
}
public void addForce(float dir)
{
rb.AddForce(new Vector2(7000.0f * dir, 6000.0f));
}
private void bomb()
{
colliders = Physics2D.OverlapCircleAll(transform.position, 5.0f);
foreach( Collider2D collider in colliders )
{
if( collider.tag == "Road" )
{
Destroy(collider.gameObject);
}
}
Destroy(this.transform.parent.gameObject);
}
}
DemolishingBomb 클래스입니다.