25 lines
513 B
C#
25 lines
513 B
C#
using UnityEngine;
|
|
|
|
public class BlockDrop_Bullet : MonoBehaviour
|
|
{
|
|
public float speed = 25f;
|
|
public int damage = 1;
|
|
public float life = 3f;
|
|
|
|
void Start() { Destroy(gameObject, life); }
|
|
|
|
void Update()
|
|
{
|
|
transform.position += transform.forward * speed * Time.deltaTime;
|
|
}
|
|
|
|
void OnTriggerEnter(Collider other)
|
|
{
|
|
if (other.TryGetComponent<BlockDrop_Block>(out var block))
|
|
{
|
|
block.Hit(damage);
|
|
Destroy(gameObject);
|
|
}
|
|
}
|
|
}
|