-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBulletScript.cs
57 lines (48 loc) · 1.09 KB
/
BulletScript.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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BulletScriptt : MonoBehaviour
{
[SerializeField]
float speed = 5f;
[SerializeField]
int damage;
Rigidbody2D rb2d;
[SerializeField]
public CommonEnemy enemy;
public void StartShooting(bool isFacingLeft)
{
rb2d = GetComponent<Rigidbody2D>();
if (isFacingLeft)
{
rb2d.velocity = new Vector2(-speed, 0);
}
else
{
rb2d.velocity = new Vector2(speed, 0);
}
Destroy(gameObject, 5f);
}
/*
private void OnTriggerEnter2D (Collider2D hitInfo)
{
CommonEnemy enemy = hitInfo.GetComponent<CommonEnemy>();
if (enemy != null)
{
enemy.TakeDamage(1);
}
Destroy(gameObject);
}
*/
private void Collision2D (Collider2D collision)
{
if(collision.CompareTag("Ground"))
{
Destroy(gameObject);
}
if(collision.CompareTag("Enemy"))
{
Destroy(gameObject);
}
}
}