-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDmg_Taken.cs
65 lines (40 loc) · 951 Bytes
/
Dmg_Taken.cs
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Dmg_Taken : MonoBehaviour
{
public float curHealth = 0;
public float maxHealth = 100;
public Animator animator;
bool dmg_anim = false;
void start()
{
curHealth = maxHealth;
}
void Awake()
{
animator = gameObject.GetComponent<Animator>();
}
void Update()
{
if (curHealth <= 0)
{
Destroy(gameObject);
}
}
public void Damage(int damage)
{
curHealth -= damage;
}
/* private void OnCollisionEnter2D(Collision2D collision)
{
if (collision.gameObject.tag == "player2")
{
animator.SetTrigger("Hit");
}
else
{
animator.SetTrigger("idle2");
}
}*/
}