blob: 49ede52e1f8997e5041ee331316b9525b9487d7b (
plain)
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 UnityEngine;
using System.Collections;
public class Enemy3BulletScript : MonoBehaviour {
bool fired;
void Start()
{
fired = false;
}
void Update()
{
}
void OnTriggerEnter2D(Collider2D col)
{
if (!fired)
{
var player = col.gameObject.GetComponentInParent<PlayerHealthScript>();
if (player != null)
{
fired = true;
player.TakeDamage(20f);
Destroy(gameObject);
}
}
}
}
|