// ***********************************************************************
// Assembly : Game
// Author : Kimch
// Created : 2020-09-02
// Description :
// Last Modified By :
// Last Modified On :
// ***********************************************************************
//
//
// ***********************************************************************
using UnityEngine;
namespace G
{
///
/// 触发子弹
///
public class Bullet_trigger : MonoBehaviour
{
///
///
///
public float bullet_speed;
///
///
///
public Transform bullet_splash;
private Transform _splash;
private float _delayFinish;
private void Start()
{
_splash = Instantiate(bullet_splash, transform.position, Quaternion.identity);
_splash.gameObject.SetActive(false);
_splash.GetComponent().mass = this.GetComponent().mass;
}
private void OnTriggerEnter(Collider other)
{
if (other.gameObject.layer == GameLayer.UnitLayer)
{
_splash.position = this.transform.position + this.transform.forward * 0.1f;
_splash.gameObject.SetActive(true);
this.gameObject.SetActive(false);
this.transform.position = Vector3.one * 4f;
}
}
private void Update()
{
if (_delayFinish > 0.4f)
{
_delayFinish = 0f;
this.gameObject.SetActive(false);
}
this.transform.Translate(Vector3.forward * (Time.deltaTime * bullet_speed));
}
}
}