2025-05-18 01:04:31 +08:00

68 lines
1.6 KiB
C#

// ***********************************************************************
// Assembly : Game
// Author : Kimch
// Created : 2020-09-02
// Description :
// Last Modified By :
// Last Modified On :
// ***********************************************************************
// <copyright file= "BulletPet3" company="Kimch"></copyright>
// <summary></summary>
// ***********************************************************************
using UnityEngine;
namespace G
{
/// <summary>
///
/// </summary>
public class BulletPet3 : MonoBehaviour
{
private Transform _fx;
//private LineRenderer _myline;
private Vector3 _targetPos;
private Vector3 _direction;
private float _delay;
private void Awake()
{
//_myline = GetComponent<LineRenderer>();
_fx = transform.GetChild(0);
this.gameObject.SetActive(false);
}
private void OnEnable()
{
_targetPos = transform.position + transform.forward * 0.3f;
_targetPos.y = 0.005f;
_direction = transform.forward;
_direction.y = 0f;
_delay = 2.8f;
transform.rotation = Quaternion.identity;
_fx.forward = _direction;
}
private void Update()
{
_direction += _fx.right * Time.deltaTime * 6f;
_direction.y = 0f;
_targetPos += _direction * Time.deltaTime * 1f;
Vector3 position = EntityPet.Instance.position;
//_myline.SetPosition(0, position);
//_myline.SetPosition(1, _targetPos);
_fx.position = _targetPos;
_fx.forward = _direction;
if (_delay < 0f)
{
EntityPet.Instance.AttackFinish();
this.gameObject.SetActive(false);
}
_delay -= Time.deltaTime;
}
}
}