반응형
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | using System.Collections; using System.Collections.Generic; using UnityEngine; public class EnemyHealth : MonoBehaviour { public int maxHealth = 100; public int currentHealth; private ParticleSystem hitParticle; public void Awake() { currentHealth = maxHealth; hitParticle = GetComponentInChildren<ParticleSystem>(); } public void TakeDamage(int damage, Vector3 hitPoint) { if (currentHealth <= 0) return; currentHealth -= damage; if (currentHealth <= 0) Destroy(gameObject); hitParticle.transform.position = hitPoint; hitParticle.Play(); } } | cs |
반응형
'etc-posts > Unity :: C# 튜토리얼' 카테고리의 다른 글
[유니티C#][기초] 13. 튜토리얼 SurvivalShooter 정리.2 (0) | 2018.07.08 |
---|---|
[유니티C#][기초] 12. 튜토리얼 SurvivalShooter 정리.1 (0) | 2018.07.08 |
[유니티C#][기초] 10.플레이어 슈팅 5 (최종) (0) | 2018.07.08 |
[유니티C#][기초] 9. 플레이어 슈팅 4 (0) | 2018.07.08 |
[유니티C#][기초] 8. 플레이어를 따라오는 적 만들기 (0) | 2018.07.08 |