Guns spin and die and self destruct on impact

This commit is contained in:
2024-10-27 18:30:18 -07:00
parent 73ab694f7c
commit e3a96303bc
3 changed files with 11 additions and 5 deletions

View File

@@ -3,9 +3,15 @@ using UnityEngine;
public class Gun : MonoBehaviour
{
public float damageStrength;
void OnTriggerEnter2D (Collider2D hit) {
if (hit.tag == "Player") {
hit.GetComponent<Teo>().health -= damageStrength;
}
// Damage player and destroy self on impact
if (hit.tag != "Player") return;
hit.GetComponent<Teo>().health -= damageStrength;
Destroy(gameObject);
}
void Update() {
transform.Rotate(new Vector3 (0, 0, Time.deltaTime * 1000));
}
}