발사
발사라던가 제작했습니다만 .. 데미지 구현은 모르겠고 큐 효율성을 높여주세요
This commit is contained in:
23
Assets/Scripts/LivingEntity.cs
Normal file
23
Assets/Scripts/LivingEntity.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
public class LivingEntity : MonoBehaviour
|
||||
{
|
||||
public float health;
|
||||
public void Damage(float amount)
|
||||
{
|
||||
health -= amount;
|
||||
if (health <= 0)
|
||||
{
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
private void OnTriggerEnter2D(Collider2D other)
|
||||
{
|
||||
if (other.gameObject.layer == LayerMask.NameToLayer("Bullet"))
|
||||
{
|
||||
Destroy(gameObject);
|
||||
other.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user