xirang/Assets/scripts/Bullet.cs
杨号敬 5cce41cb28 add
2024-11-27 00:06:28 +08:00

31 lines
733 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Bullet : MonoBehaviour
{
public int harm;
private void Start()
{
Destroy(this.gameObject,1f);
}
private void OnCollisionEnter(Collision collision)
{
if (collision.gameObject.CompareTag("enemy"))
{
Enemy enemy = collision.gameObject.GetComponent<Enemy>();
enemy.EnemyHpDown(harm);
Destroy(this.gameObject);
}
if (collision.gameObject.CompareTag("ore"))
{
Ore ore = collision.gameObject.GetComponent<Ore>();
ore.OreHpDown(harm);
Destroy(this.gameObject);
}
}
}