make bullets go dissapear when hit something

This commit is contained in:
Sofia 2019-08-04 02:10:18 +03:00
parent 5f408e896c
commit 66dec3d98c
2 changed files with 9 additions and 8 deletions

View File

@ -15,5 +15,14 @@ namespace Saltosion.OneWeapon.Bullets {
Body.velocity = Direction * 15;
Body.rotation = Rot - 90;
}
void OnTriggerEnter2D(Collider2D collider) {
if (collider.GetComponent<Player>() != null) {
// don't hit the player!
return;
}
Destroy(gameObject);
Debug.Log("Boom!");
}
}
}

View File

@ -10,14 +10,6 @@ namespace Saltosion.OneWeapon {
private bool IsHeld = false;
void Start() {
}
void Update() {
}
void OnTriggerEnter2D(Collider2D collider) {
if (IsHeld) {
return;