Implemented lives system

This commit is contained in:
Gregory Campbell
2020-07-11 14:53:27 -04:00
parent 5ef8a35f08
commit c1efe59c11
8 changed files with 443 additions and 4 deletions
+11 -4
View File
@@ -6,9 +6,9 @@ public class PlayerScript : MonoBehaviour
{
public float speed;
public GameObject bullet;
private int life = 3;
private float translation;
private float rotation;
private float nextFire = 0.5f;
@@ -36,11 +36,16 @@ public class PlayerScript : MonoBehaviour
if(Input.GetButton("Fire1") && myTime > nextFire)
{
nextFire = myTime + 0.5f;
GunFire(Random.Range(0.0f, 360.0f));
GunFire();
nextFire = nextFire - myTime;
myTime = 0.0f;
}
if(life <= 0)
{
Destroy(gameObject);
}
}
void FixedUpdate()
@@ -62,12 +67,14 @@ public class PlayerScript : MonoBehaviour
if(other.gameObject.tag == "Enemy")
{
Destroy(gameObject);
life--;
Destroy(GameObject.FindWithTag("Life"));
}
}
void GunFire(float aim)
void GunFire()
{
int gunSelect = 0;